//聯(lián)系人:石虎QQ: 1224614774昵稱:嗡嘛呢叭咪哄
1.打開數(shù)據(jù)庫
intsqlite3_open(
constchar*filename,//數(shù)據(jù)庫的文件路徑
sqlite3 **ppDb//數(shù)據(jù)庫實(shí)例
);
2.執(zhí)行任何SQL語句
intsqlite3_exec(
sqlite3*,//一個打開的數(shù)據(jù)庫實(shí)例
constchar*sql,//需要執(zhí)行的SQL語句
int(*callback)(void*,int,char**,char**),// SQL語句執(zhí)行完畢后的回調(diào)
void*,//回調(diào)函數(shù)的第1個參數(shù)
char**errmsg//錯誤信息
);
3.檢查SQL語句的合法性(查詢前的準(zhǔn)備)
intsqlite3_prepare_v2(
sqlite3 *db,//數(shù)據(jù)庫實(shí)例
constchar*zSql,//需要檢查的SQL語句
intnByte,// SQL語句的最大字節(jié)長度
sqlite3_stmt **ppStmt,// sqlite3_stmt實(shí)例,用來獲得數(shù)據(jù)庫數(shù)據(jù)
constchar**pzTail
);
4.查詢一行數(shù)據(jù)
intsqlite3_step(sqlite3_stmt*);//如果查詢到一行數(shù)據(jù),就會返回SQLITE_ROW
5.利用stmt獲得某一字段的值(字段的下標(biāo)從0開始)
doublesqlite3_column_double(sqlite3_stmt*,intiCol);//浮點(diǎn)數(shù)據(jù)
intsqlite3_column_int(sqlite3_stmt*,intiCol);//整型數(shù)據(jù)
sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*,intiCol);//長整型數(shù)據(jù)
constvoid*sqlite3_column_blob(sqlite3_stmt*,intiCol);//二進(jìn)制文本數(shù)據(jù)
constunsignedchar*sqlite3_column_text(sqlite3_stmt*,intiCol);//字符串?dāng)?shù)據(jù)