From 534c5958af6104aea60a9fcb0d823a5c3cfed1bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Mar 2011 13:09:06 +0200 Subject: SQLite support --- hello/database.hxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'hello') diff --git a/hello/database.hxx b/hello/database.hxx index 6616cfe..1bdd454 100644 --- a/hello/database.hxx +++ b/hello/database.hxx @@ -18,6 +18,9 @@ #if defined(DATABASE_MYSQL) # include +#elif defined(DATABASE_SQLITE) +# include +# include #endif inline std::auto_ptr @@ -33,14 +36,30 @@ create_database (int& argc, char* argv[]) #if defined(DATABASE_MYSQL) odb::mysql::database::print_usage (cerr); +#elif defined(DATABASE_SQLITE) + odb::sqlite::database::print_usage (cerr); #endif exit (0); } #if defined(DATABASE_MYSQL) - return auto_ptr (new odb::mysql::database (argc, argv)); + auto_ptr db (new odb::mysql::database (argc, argv)); +#elif defined(DATABASE_SQLITE) + auto_ptr db ( + new odb::sqlite::database ( + argc, argv, false, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); + + // Create the database schema. + // + { + transaction t (db->begin ()); + schema_catalog::create_schema (*db); + t.commit (); + } #endif + + return db; } #endif // DATABASE_HXX -- cgit v1.1