Blob example using an in-memory database

This commit is contained in:
Sébastien Rombauts 2013-03-09 23:00:02 +01:00
parent 65ad65b40c
commit 44fde46e2a
3 changed files with 3 additions and 12 deletions

View File

@ -1,13 +1,8 @@
Add a Changelog
C++11 explicit support C++11 explicit support
Update Doxygen Documentation, but remove it from the master branch Update Doxygen Documentation, but remove it from the master branch
Publish the Doxygen Documentation in the Github Pages (gh-pages branch) Publish the Doxygen Documentation in the Github Pages (gh-pages branch)
Missing test/example in v0.5.0:
- :memory: table
Missing features in v0.5.0: Missing features in v0.5.0:
- bind a SQLITE_STATIC value (string/blob) - bind a SQLITE_STATIC value (string/blob)
- bind a dynamic value with zerocopy (unlike SQLITE_TRANSIENT) with custom deleter - bind a dynamic value with zerocopy (unlike SQLITE_TRANSIENT) with custom deleter
@ -17,8 +12,7 @@ Missing documentation in v0.5.0:
- This wrapper is not thread safe : compare to the thread safety of the SQLite3 library - This wrapper is not thread safe : compare to the thread safety of the SQLite3 library
Advanced missing features: Advanced missing features:
- :memory: : use the "zVfs" (last) parameter of sqlite3_open_v2() to give access to the ":memory:" VFS module - backup support to/from file/:memory:
- backup support to/from :memory:
- batch mode managing multiple queries semicolon separated ? - batch mode managing multiple queries semicolon separated ?
- Function ? - Function ?
- Agregate ? - Agregate ?

View File

@ -19,8 +19,6 @@ Database::Database(const char* apFilename, const int aFlags /*= SQLITE_OPEN_READ
mpSQLite(NULL), mpSQLite(NULL),
mFilename(apFilename) mFilename(apFilename)
{ {
// TODO SRombauts : use the "zVfs" (last) parameter to give access to the ":memory:" VFS module
// TODO SRombauts : then add a backup mode to/from ":memory:"
int ret = sqlite3_open_v2(apFilename, &mpSQLite, aFlags, NULL); int ret = sqlite3_open_v2(apFilename, &mpSQLite, aFlags, NULL);
if (SQLITE_OK != ret) if (SQLITE_OK != ret)
{ {

View File

@ -261,11 +261,11 @@ int main (void)
remove("transaction.db3"); remove("transaction.db3");
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Binary blob example (6/6) : // Binary blob and in-memory database example (6/6) :
try try
{ {
// Open a database file in create/write mode // Open a database file in create/write mode
SQLite::Database db("blob.db3", SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); SQLite::Database db(":memory:", SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
std::cout << "SQLite database file '" << db.getFilename().c_str() << "' opened successfully\n"; std::cout << "SQLite database file '" << db.getFilename().c_str() << "' opened successfully\n";
db.exec("DROP TABLE IF EXISTS test"); db.exec("DROP TABLE IF EXISTS test");
@ -326,7 +326,6 @@ int main (void)
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program abort(); // unexpected error : abort the example program
} }
remove("blob.db3");
remove("out.png"); remove("out.png");
std::cout << "everything ok, quitting\n"; std::cout << "everything ok, quitting\n";