aboutsummaryrefslogtreecommitdiff
path: root/qt/database.hxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-04-11 18:21:12 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-04-22 18:45:40 +0200
commit7ee76c54fca21bed2b94ebf1e71f723670f135fe (patch)
tree9d8e967c58728189e5923a8ce9b9f8fa87010641 /qt/database.hxx
parent5da0df2986a62e1254d27c8cfbc383ba580555e1 (diff)
Add SQLite support to Qt example
Diffstat (limited to 'qt/database.hxx')
-rw-r--r--qt/database.hxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/qt/database.hxx b/qt/database.hxx
index c7c6957..5b96ae9 100644
--- a/qt/database.hxx
+++ b/qt/database.hxx
@@ -18,6 +18,10 @@
#if defined(DATABASE_MYSQL)
# include <odb/mysql/database.hxx>
+#elif defined(DATABASE_SQLITE)
+# include <odb/transaction.hxx>
+# include <odb/schema-catalog.hxx>
+# include <odb/sqlite/database.hxx>
#endif
inline std::auto_ptr<odb::database>
@@ -33,14 +37,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<database> (new odb::mysql::database (argc, argv));
+ auto_ptr<database> db (new odb::mysql::database (argc, argv));
+#elif defined(DATABASE_SQLITE)
+ auto_ptr<database> 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