| 383 | |
| 384 | public: |
| 385 | database(const std::string &db_name, const sqlite_config &config = {}): _db(nullptr) { |
| 386 | sqlite3* tmp = nullptr; |
| 387 | auto ret = sqlite3_open_v2(db_name.data(), &tmp, static_cast<int>(config.flags), config.zVfs); |
| 388 | _db = std::shared_ptr<sqlite3>(tmp, [=](sqlite3* ptr) { sqlite3_close_v2(ptr); }); // this will close the connection eventually when no longer needed. |
| 389 | if(ret != SQLITE_OK) errors::throw_sqlite_error(_db ? sqlite3_extended_errcode(_db.get()) : ret); |
| 390 | sqlite3_extended_result_codes(_db.get(), true); |
| 391 | if(config.encoding == Encoding::UTF16) |
| 392 | *this << R"(PRAGMA encoding = "UTF-16";)"; |
| 393 | } |
| 394 | |
| 395 | database(const std::u16string &db_name, const sqlite_config &config = {}): _db(nullptr) { |
| 396 | #ifdef _MSC_VER |
nothing calls this directly
no test coverage detected