这里是文章模块栏目内容页
sqlite+api文档

SQLite是一个轻量级的嵌入式数据库,它不需要另外的服务器进行支持,也不需要特别的管理。由于其小巧、易于使用、低成本,因此在很多SDK中都会预装SQLite作为存储介质。

SQLite API 是一套C语言函数集合,能够帮助开发者创建、删除、保存数据库文件并构造条目等。API 具有显著的扩展性:它能够在大部分流行的Unix/Linux平台上运行 。

1. sqlite3_open()函数: 连接/打开 SQLite 数据库文件,如 :

int sqlite3_open(const char *filename,sqlite3 **ppDb);

filename: 数据库文件名; ppDb: 已打开数据库对象; 返回 0 (ok) 或 错误代号.

//例子 :

#include

#include "sqlite3.h" //sqliten lib header file

int main(){ sqliten *db ; if( sq l ite 3 _ open (" myd b . db ",& d b ) ! = SQLITE_OK){ printf(" failed to open database \n"); return -1; } else { printf(" succeeded in opening database \n"); } }

2. sqlite3_prepare()函数: 生成sql语句 , 如 :int sql it e 3 _ prep are (sq lit en* db, const ch ar* sq l , i nt len , s qli t e 3 _ st m t** stmt , con s t c h a r** ta il );

db :已打开的 DB ojbect ; sq l : SQ L 语句; len :sq l 长 度 ; stmt :生成 状態 ment o jbects ; tail :un used para me ter . //例子 :# include #in clu de "sq li te 3 .h" int ma in (){ cha r *zSQ L = "sele ct id from table 1"; sq li ten *d b=NULL; s ql it en _ smtm t* smtm=NULL