我决定使用SQLite,因为它允许将数据库存储到单个文件中.我想我已经成功地用SQLite Database Browser建立了一个数据库.
如何在C/C++程序中读取这些数据?
我决定使用SQLite,因为它允许将数据库存储到单个文件中.我想我已经成功地用SQLite Database Browser建立了一个数据库.
如何在C/C++程序中读取这些数据?
‘An Introduction to Sqlite C/C++ Interface’怎么样,这里有一个完整的C++示例here on CodeProject.
这是更完整的样本的一部分,
#include "CppSQLite.h"
#include <ctime>
#include <iostream>
using namespace std;
const char* gszFile = "C:\\test.db";
int main(int argc, char** argv)
{
try
{
int i, fld;
time_t tmStart, tmEnd;
CppSQLiteDB db;
cout << "SQLite Version: " << db.SQLiteVersion() << endl;
db.open(gszFile);
cout << db.execScalar("select count(*) from emp;")
<< " rows in emp table in ";
db.Close();
}
catch (CppSQLiteException& e)
{
cerr << e.errorCode() << ":" << e.errorMessage() << endl;
}
}