sqlite3* m_db = NULL;
int ret = sqlite3_open_v2("test.db",&db,sqlITE_OPEN_READWRITE,NULL);
if (ret != sqlITE_OK)
{
return;
}
2 如果表不存在,创建表
char szCreateUserDatasql[1024] = "create table if not exists tb_user (id INTEGER,\
type INTEGER,255);"> kind INTEGER)";
3 创建唯一的主键ID
char szCreateUserDatasql[1024] = "create table if not exists tb_user (id INTEGER PRIMARY KEY AUTOINCREMENT,255);">4 查询
char szsql[1024] = {0};
sprintf(szsql,"select distinct * from tb_test");
sqlite3_stmt* stmt = NULL;
sqlite3_prepare(m_db,szsql,-1,&stmt,0);
while (sqlite3_step(stmt) == sqlITE_ROW)
const unsigned char* szPOIName = sqlite3_column_text(stmt,255);"> char szName[128] = {0};
if (szPOIName)
{
sprintf(szName,"%s",szPOIName);
}
int kx = sqlite3_column_int(stmt,3);
float x = sqlite3_column_double(stmt,5);
sqlite3_finalize(stmt);
char* errMsg = NULL;
char* szsql = "select * from address";
nRet = sqlite3_exec(pDB,NULL,&errMsg);
if (nRet != sqlITE_OK)
{
cout<<errMsg<<endl;
sqlite3_free(errMsg);
}
注意:释放errMsg指向的内存
sqlite3_close(db);