SQLite 粗劣内容

SQLite 的官网

http://addons.mozillan.org/firefox/addon/sqlite-manager/

http://www.sqlite.org

 

sqlite3 *sqlite = nil;

    

    NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/data.file" ];

    

    //打开数据库

    int result  = sqlite3_open([filePath  UTF8String], &sqlite);

    if (result !=SQLITE_OK) {

        NSLog(@"创建失败!!!");

        return ;

    }

    

    //创建表的SQL语句

    

    NSString *sql = @"CREATE TABLE IF NOT EXISTS UserTable(userName text PRIMARY KEY ,password text,email text)";

    //执行SQL语句

    char *error;

    result = sqlite3_exec(sqlite, [sql  UTF8String], NULL, NULL, &error);

    if (result != SQLITE_OK) {

        NSLog(@"创建数据库失败:%s",error);

        return ;

    }

    //插如入一条数据

    //INSERT OR REPLACE INTO UserTable (userName,password,email) VALUES(?,?,?);

    //更新一条数据

    //UPDATE UserTable set password = '' where userName = '';

    

    //查询数据

    

    //SELECT userName ,password,eamil FROM UserTable where username = '';

   

    //删除数据

   // DELETE FROM UserTable WHERE username ='';

    

    //关闭数据库

    

    sqlite3_close(sqlite);

原文地址:https://www.cnblogs.com/meixian/p/5371114.html