数据库在IOS Sqlite3和db [英] Database in IOS Sqlite3 and db

查看:227
本文介绍了数据库在IOS Sqlite3和db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS数据库中学习一些概念...我知道sqlite3(开源)用于数据库,
,但我正在通过一些github代码...

I am learning some concepts in the iOS database... I come to know that sqlite3 (open source ) is used for databases, but I was going through some of the github code...

,并遇到以下两行:

NSString *sqLiteDb = [[NSBundle mainBundle] pathForResource:@"banklist" 
        ofType:@"sqlite3"]

/ p>

and

 NSString *databaseFilename =@"abc.db"




  1. 您可以告诉我们在哪里使用 sqlite3 ,其中 db

  2. 你还可以提供一些好的链接来学习iOS数据库(从示例项目中打开 db 文件在textedit我不明白它)?

  3. 如何打开 db 文件和 sqlite 文件?

  4. 是否有任何免费工具可用于读取这些数据库文件?

  1. can you please tell me where we will use the sqlite3 and where db?
  2. can you also provide me some good links to learn the database for the iOS (from the sample project when I open the db file in the textedit I can't understand it)?
  3. how can I open the db file and sqlite file?
  4. is there any free tool is available in iOS to read these database files?


推荐答案

您问:


您可以告诉我们在哪里使用 sqlite3 db

您可以使用任一扩展名。没关系。 sqlite (不含3)和 db 都是常用的。

You can use either extension. It doesn't matter. Both sqlite (without the 3) and db are commonly used.


您还可以为我提供一些好的链接,以了解iOS的数据库

can you also provide me some good links to learn the database for the iOS

ios sqlite教程

Google "ios sqlite tutorial"

我一般喜欢Ray Wenderlich教程,他的SQLite教程在这里: SQLite 101 for iPhone开发人员:使我们的应用程序。我对这个教程的唯一批评是,我不喜欢他打开一个数据库从包。您应该始终将数据库从bundle复制到Documents文件夹,然后在Documents文件夹中打开数据库。

I generally like Ray Wenderlich tutorials and his SQLite tutorial is here: SQLite 101 for iPhone Developers: Making Our App. My only criticism of that tutorial is that I don't like the fact that he's open a database from the bundle. You should always copy database from bundle to Documents folder first, before opening the database in the Documents folder.


如何打开数据库文件和sqlite文件

how can i open the db file and sqlite file

您打开数据库(即一个文件,通常使用 db sqlite 扩展)。它是同一类文件,只是一个不同的扩展。一般过程是:

You open databases (i.e., a file, conventionally with either db or sqlite extension) the same way. It's the same sort of file, just a different extension. The general process is either:


  • 在您的Mac上创建数据库,并将其包含在项目和结果包中。然后,以编程方式检查文档文件夹中是否已存在数据库,如果不存在,则从捆绑包复制到文档文件夹(如果这样做,您可能需要使用 sqlite3_open_v2 SQLITE_OPEN_READWRITE 选项, $ c> SQLITE_OPEN_CREATE 选项,因此如果没有找到数据库,将不会创建);或

  • Create database on your mac and include it in the project and the resulting bundle. Then, programmatically you check to see if database already exists in the Documents folder and, if not, copy from the bundle to Documents folder (if you do this, you might want to use sqlite3_open_v2 with the SQLITE_OPEN_READWRITE option, but not the SQLITE_OPEN_CREATE option, so the database won't be created if it's not found); or

以编程方式通过以下方式创建数据库:a)检查文档中是否存在数据库,如果没有,使用 sqlite3_open_v2 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE 选项或仅 sqlite3_open (默认情况下使用这两个选项))然后执行SQL CREATE 语句;

Create database programmatically by (a) check to see if it exists in Documents and if not, create database (with either sqlite3_open_v2 with the SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE options or just sqlite3_open (which uses those two options by default)) and then execute the SQL CREATE statements; or (b) if it already exists in the Documents folder, just use it.

如果您经历了各种教程,你会发现,他们会带你通过或接近或其他。这两种技术都是有效的。

If you go through the various tutorials you find, they'll walk you through or approach or the other. Both techniques are valid.


有任何免费工具可以在iOS中读取这些数据库文件

is there any free tool is available in iOS to read these database files

我不认为有iOS工具(因为应用程序保存他们的文件(和数据库只是一种类型的文件)在各自的沙箱,因此一个应用程序可以' t在另一个应用程序的文档文件夹中打开数据库)。但是在开发过程中有许多Mac工具。

I don't think there are iOS tools (as apps keep their files (and a database is just a type of file) in their respective sandboxes and thus one app can't open a database in another app's Documents folder). But there are lots of Mac tools that you use during development.


  • sqlite3

我使用基础,一个相当基本的工具

I use Base, an ok, fairly basic tool

我认为很多人使用FireFox SQLite Manager 工具

I think a lot of people use a FireFox SQLite Manager tool

您没有要求,但如果您要开始SQLite开发,请使用 FMDB 可以大大地 简化您的Objective-C代码。如果我没有注意到核心数据是iOS开发的首选数据库技术。使用SQLite(例如,通过FMDB)可能有令人信服的理由,但是苹果设计了丰富的Core Data框架,这对于仅iOS应用程序有一些优势。这有点复杂,但有一些优势。

You didn't ask, but if you're starting SQLite development, using FMDB can greatly simplify your Objective-C code. And I'd be remiss if I didn't note the Core Data is the preferred database technology for iOS development. There can be compelling reasons to use SQLite (via FMDB, for example), but Apple engineered the rich Core Data framework that has some advantages for iOS-only apps. It's a little more complicated, but has some advantages.

这篇关于数据库在IOS Sqlite3和db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆