MCPcopy Create free account
hub / github.com/SqliteModernCpp/sqlite_modern_cpp / database

Method database

hdr/sqlite_modern_cpp.h:385–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

throw_sqlite_errorFunction · 0.85

Tested by

no test coverage detected