zoukankan      html  css  js  c++  java
  • iOS下使用sqlite3

    1、创建数据库

    使用firefox的sqlite manager创建和打开数据库,详细请参考:

    http://www.cnblogs.com/hanjun/archive/2012/10/29/2744573.html

    2、导入数据

    sqlite manager支持csv 和sql两种导入方式。

    导入时默认的编码为utf-8,导入后如果数据乱码,可以尝试使用gb2312编码重新导入。

    3、调用数据库

    很多教程说从Document文件夹读取数据库,读取方法为:

      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 

      NSString *documentsDirectory = [paths objectAtIndex:0]; 

      self.databaseFilePath = [documentsDirectory stringByAppendingPathComponent:kDatabaseName]; 

    我尝试把数据库文件(data.sqlite)附加到Supporting FIles下,用下面的方式读取:

      NSString *filePath = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"sqlite"];

    事实上是没有问题的。

    增删改之类的操作和sqlserver没有多大的区别,网上一大把,这里就不重复了。

  • 相关阅读:
    form表单数据进行json转换
    spring整合quartz时间任务调度框架
    quartz之hello(java)
    spring整合activeMq
    activeMq之hello(java)
    spring整合redis之hello
    redis之hello
    jpa命名规范
    webservice之helloword(web)rs
    webService之helloword(java)rs
  • 原文地址:https://www.cnblogs.com/JayK/p/4029084.html
Copyright © 2011-2022 走看看