aboutsummaryrefslogtreecommitdiff
path: root/schema
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-25 13:09:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-25 13:09:06 +0200
commit534c5958af6104aea60a9fcb0d823a5c3cfed1bc (patch)
treec2488c68b31a3b72526a7db017d4997cdb93f91f /schema
parent0bea9feb8e97b0257b801f34322db72a01373468 (diff)
SQLite support
Diffstat (limited to 'schema')
-rw-r--r--schema/custom/database.hxx12
-rw-r--r--schema/embedded/database.hxx20
2 files changed, 30 insertions, 2 deletions
diff --git a/schema/custom/database.hxx b/schema/custom/database.hxx
index 88536ab..932e6c4 100644
--- a/schema/custom/database.hxx
+++ b/schema/custom/database.hxx
@@ -18,6 +18,8 @@
#if defined(DATABASE_MYSQL)
# include <odb/mysql/database.hxx>
+#elif defined(DATABASE_SQLITE)
+# include <odb/sqlite/database.hxx>
#endif
inline std::auto_ptr<odb::database>
@@ -33,14 +35,22 @@ 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));
#endif
+
+ return db;
}
#endif // DATABASE_HXX
diff --git a/schema/embedded/database.hxx b/schema/embedded/database.hxx
index 7483f52..ab733e2 100644
--- a/schema/embedded/database.hxx
+++ b/schema/embedded/database.hxx
@@ -18,6 +18,8 @@
#if defined(DATABASE_MYSQL)
# include <odb/mysql/database.hxx>
+#elif defined(DATABASE_SQLITE)
+# include <odb/sqlite/database.hxx>
#endif
inline std::auto_ptr<odb::database>
@@ -33,14 +35,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