开发语言:C++。
cd D:\sqlite\sqlite-dll-win32-x86-3071300
D:
lib /def:sqlite3.def /machine:ix86
即可生成sqlite3.lib文件。
cd D:\sqlite
d:
创建test.db测试文件。
字段Code | 字段类型 | 字段描述 |
id | integer | 主键,自增 |
name | varchar(64) | 用户名 |
age | integer | 年龄 |
D:\sqlite>sqlite3.exe test.db
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table user
...> (
...> id integer primary key autoincrement,
...> name varchar(64),
...> age integer
...> );
sqlite> .quit
/*
@brief 本程序测试sqlite数据库的增删改查
@date 2012-09-03
*/
// SQLiteTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "sqlite3.h"
#include
using namespace std;
sqlite3 * pDB = NULL;
//增加用户
bool AddUser(const string& sName, const string& sAge);
//删除用户
bool DeleteUser(const string& sName);
//修改用户
bool ModifyUser(const string& sName, const string& sAge);
//查找用户
bool SelectUser();
int _tmain(int argc, _TCHAR* argv[])
{
//打开路径采用utf-8编码
//如果路径中包含中文,需要进行编码转换
int nRes = sqlite3_open("D:\\sqlite\\test.db", &pDB);
if (nRes != SQLITE_OK)
{
cout<<"Open database fail: "<
add user success: zhao 18
add user success: qian 19
add user success: sun 20
add user success: li 21
delete user success: zhao
modify user success: sun 15
id = 2, name = qian, age = 19,
id = 3, name = sun, age = 15,
id = 4, name = li, age = 21,
可视化管理工具,推荐使用:SQLite Expert,见:http://www.sqliteexpert.com/。