diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-28 16:07:38 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-28 16:07:38 +0200 |
commit | b9764c3eb6626fb96deb0901b9ee63c2246ff52e (patch) | |
tree | af583f5fcfa512638f47c153cc54d827936766a1 /odb/sqlite/connection.cxx | |
parent | 7392db256c1587ff8fe87d95c5ae5c10f854f79e (diff) |
Add support for creating connection from existing handle
This will allow for custom connection establishment and configuration.
Diffstat (limited to 'odb/sqlite/connection.cxx')
-rw-r--r-- | odb/sqlite/connection.cxx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 1e9ff6f..68b57f9 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -66,16 +66,35 @@ namespace odb translate_error (e, *this); } + init (); + } + + connection:: + connection (database_type& db, sqlite3* handle) + : odb::connection (db), + db_ (db), + handle_ (handle), + unlock_cond_ (unlock_mutex_), + statements_ (0) + { + init (); + } + + void connection:: + init () + { // Enable/disable foreign key constraints. // simple_statement st ( *this, - db.foreign_keys () + db_.foreign_keys () ? "PRAGMA foreign_keys=ON" : "PRAGMA foreign_keys=OFF", - db.foreign_keys () ? 22 : 23); + db_.foreign_keys () ? 22 : 23); st.execute (); + // Create statement cache. + // statement_cache_.reset (new statement_cache_type (*this)); } |