/*
* sqltest.cpp
*
* Created on: 2011-2-9
* Author: zhl
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include "sqlite3.h"
char DBFileName[80];
char DBTableName[20];
int main( int argc,char* argv[] )
{
char SqlStr[256];
char* ErrMsg;
char str[64];
int startidx;
int i1, rc;
time_t t;
struct tm *p;
sqlite3* db;
printf( "Sqlite3 Test V1.0\n" );
// 解析命令行参数,获取DB文件名
if( argc > 1 )
{
startidx = atoi(argv[1]);
}
else
{
startidx = 0;
}
strcpy( DBFileName, "/mnt/nandflash/db2");
strcpy( DBTableName, "t1");
rc = sqlite3_open( DBFileName, &db );
sprintf( SqlStr, "create table %s(Name char(50), Value int, Date char(50))",
DBTableName );
//i1 = sql_exec( SqlStr );
sqlite3_exec( db, SqlStr, 0, 0, &ErrMsg );
for( i1=startidx; i1<startidx+10; i1++ )
{
time( &t );
p = localtime ( &t );
sprintf( str, "%d.%d.%d-%d:%d:%d\n", p->tm_year + 1900, p->tm_mon+1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec );
printf("%d\n", i1+1);
sprintf(SqlStr, "insert into %s values(\"Name%d\", %d, \"%s\")",
DBTableName, i1+1, i1+1, str );
//sql_exec( SqlStr );
sqlite3_exec( db, SqlStr, 0, 0, &ErrMsg );
sleep(1);
}
sqlite3_close( db );
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
sqlite3.rar (7个子文件)
sq
libsqlite3.a 763KB
.project 2KB
.cproject 62KB
sqlite3.h 288KB
sqlite31test.rar 289KB
sqlite3ext.h 23KB
sqlite3test.cpp 1KB
共 7 条
- 1
资源评论
- KKKK2012MENG2013-07-01很好的数据库源码
- dql4680298382013-10-29还行吧,需要重新编译,根据不同的arm平台用不同的编译工具
mhf2011
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功