@@ -415,26 +415,7 @@ namespace sqlite {
415
415
std::shared_ptr<sqlite3> _db;
416
416
417
417
public:
418
- database (std::u16string const & db_name): _db(nullptr ) {
419
- sqlite3* tmp = nullptr ;
420
- auto ret = sqlite3_open16 (db_name.data (), &tmp);
421
- _db = std::shared_ptr<sqlite3>(tmp, [=](sqlite3* ptr) { sqlite3_close_v2 (ptr); }); // this will close the connection eventually when no longer needed.
422
- if (ret != SQLITE_OK) exceptions::throw_sqlite_error (ret);
423
- // _db.reset(tmp, sqlite3_close); // alternative close. (faster?)
424
- }
425
-
426
- database (std::string const & db_name): _db(nullptr ) {
427
- sqlite3* tmp = nullptr ;
428
- auto ret = sqlite3_open (db_name.data (), &tmp);
429
- _db = std::shared_ptr<sqlite3>(tmp, [=](sqlite3* ptr) { sqlite3_close_v2 (ptr); }); // this will close the connection eventually when no longer needed.
430
- if (ret != SQLITE_OK) exceptions::throw_sqlite_error (ret);
431
- // _db.reset(tmp, sqlite3_close); // alternative close. (faster?)
432
- }
433
-
434
- database (std::shared_ptr<sqlite3> db):
435
- _db (db) {}
436
-
437
- database (const std::string &db_name, const sqlite_config &config): _db(nullptr ) {
418
+ database (const std::string &db_name, const sqlite_config &config = {}): _db(nullptr ) {
438
419
sqlite3* tmp = nullptr ;
439
420
auto ret = sqlite3_open_v2 (db_name.data (), &tmp, config.flags , config.gVfs );
440
421
_db = std::shared_ptr<sqlite3>(tmp, [=](sqlite3* ptr) { sqlite3_close_v2 (ptr); }); // this will close the connection eventually when no longer needed.
@@ -443,7 +424,7 @@ namespace sqlite {
443
424
*this << R"( PRAGMA encoding = "UTF-16";)" ;
444
425
}
445
426
446
- database (const std::u16string &db_name, const sqlite_config &config): _db(nullptr ) {
427
+ database (const std::u16string &db_name, const sqlite_config &config = {} ): _db(nullptr ) {
447
428
auto db_name_utf8 = std::wstring_convert<std::codecvt_utf8_utf16<char16_t >, char16_t >().to_bytes (db_name);
448
429
sqlite3* tmp = nullptr ;
449
430
auto ret = sqlite3_open_v2 (db_name_utf8.data (), &tmp, config.flags , config.gVfs );
@@ -453,6 +434,9 @@ namespace sqlite {
453
434
*this << R"( PRAGMA encoding = "UTF-16";)" ;
454
435
}
455
436
437
+ database (std::shared_ptr<sqlite3> db):
438
+ _db (db) {}
439
+
456
440
database_binder operator <<(const std::string& sql) {
457
441
return database_binder (_db, sql);
458
442
}
0 commit comments