SQLite的C编程
打开、 关闭数据库函数
sqlite3 使用了两个库: pthread、 dl, 故链接时应加上 -lpthread 和 -ldl 。
/**
* @function: 打开数据库
* @parameter:
* db_name:数据库文件名,UTF-8 编码
* db:数据库标识,此结构体为数据库操作句柄。 通过此句柄可对数据库文件进行相应操作。
* @return {type}
* success: SQLITE_OK
* error: 非 SQLITE_OK
* @note:
*/
int sqlite3_open(char *db_name,sqlite3 **db);/**
* @function: 关闭数据库、 释放打开数据库时申请的资源。
* @parameter:
* db: 数据库的标识
* @return {type}
* success: SQLITE_OK
* error: 非 SQLITE_OK
* @note:
*/
int sqlite3_close(sqlite3 *db);Sqlite3 中执行 SQL 语句的方法 (回调方法)
栗子 sqlite3_exec .c :
Makefile
Sqlite3 中执行 SQL 语句的方法 (非回调方法)
Last updated
Was this helpful?