加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SQLite3的C编程

发布时间:2020-12-12 23:35:21 所属栏目:百科 来源:网络整理
导读:/*================================= .* The Standard include file. .* .*===============================*/ #include stdio.h #include stdlib.h /*================================= .* .* The extend include file. .* .*===========================

/*=================================
.* The Standard include file.
.*
.*===============================*/
#include <stdio.h>
#include <stdlib.h>

/*=================================
.*
.* The extend include file.
.*
.*===============================*/
#include "sqlite3.h"
/* #include "sqlite3ext.h" */

int main()
{
/* Connect SQLite system. */
sqlite3 *pDatabase = NULL;
int result;
char sql[500];
char *err_msg = NULL;
int i;

result = sqlite3_open("test.db3",&pDatabase);
if( result != SQLITE_OK ) {
printf("Failure to open the database./n");
return -1;
} else
printf("Good to open the database./n");

sprintf(sql,"BEGIN");
sqlite3_exec(pDatabase,sql,err_msg);
sprintf(sql,"CREATE TABLE [TestDB] (/
[id] int,[name] varchar(20),[age] int)");
/*
if (SQLITE_OK != sqlite3_exec(pDatabase,&err_msg)) {
printf("operate failed: %s./n",err_msg);
return -1;
}*/
for(i = 0; i < 10000; i++) {
sprintf(sql,"INSERT INTO [TestDB] ([id],[name],[age]) /
VALUES (%d,'%s',%d)",i,"JGood",i);
sqlite3_exec(pDatabase,&err_msg);
}

sprintf(sql,"END");
sqlite3_exec(pDatabase,err_msg);
sqlite3_close(pDatabase);

return 0;}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读