SQLite3++ - C++ wrapper of SQLite3 API
PROJECT STATUS
Only the
headeronly_srcdirectory is currently maintained and updated. Other directories such assrc,boost_src, and the top-leveltestdirectory are obsolete and kept only for historical reference.
This library makes SQLite3 API more friendly to C++ users. It supports almost all of SQLite3 features using C++ classes such as database, command, query, and transaction. The query class supports iterator concept for fetching records.
With ext::function class, it's also easy to use the sqlite3's functions and aggregations in C++.
// Open a database file or :memory:
sqlite3pp::database db("test.db");
// Simple execution
db.execute("INSERT INTO contacts (name, phone) VALUES ('Mike', '555-1234')");
// Move semantics
sqlite3pp::database db2 = std::move(db);// Using stream-like binder (automatically uses sqlite3pp::copy)
sqlite3pp::command cmd(db, "INSERT INTO contacts (name, phone) VALUES (?, ?)");
cmd.binder() > id >> name >> phone;
cout > sqlite3pp::ignore >> name >> phone;
cout ("log_text", [](string s) {
clog ("cpp_sum");
sqlite3pp::query qry(db, "SELECT cpp_sum(id) FROM contacts");#define SQLITE3PP_LOADABLE_EXTENSION
#include
extern "C" int sqlite3_extension_init(
sqlite3 *pdb,
char **pzErrMsg,
const sqlite3_api_routines *pApi) {
SQLITE_EXTENSION_INIT2(pApi);
// Borrow the raw sqlite3 pointer
sqlite3pp::database db(sqlite3pp::ext::borrow(pdb));
// Register functions...
return SQLITE_OK;
}To run the comprehensive test suite:
g++ -std=c++11 -Iheaderonly_src headeronly_src/test_all.cpp -lsqlite3 -o test_all && ./test_allOnly the files in headeronly_src directory are maintained. All other source and test directories (src, boost_src, test) are deprecated and should not be used for new projects.
No open issues yet, or sync has not completed.