lib/sqlite/Database: wrapper for sqlite3*

This commit is contained in:
Max Kellermann
2019-04-25 12:10:12 +02:00
parent 77c9081f78
commit a6dc1ab0a9
5 changed files with 97 additions and 13 deletions

View File

@@ -82,21 +82,12 @@ static const char sticker_sql_create[] =
"";
StickerDatabase::StickerDatabase(Path path)
:db(path.c_str())
{
assert(!path.IsNull());
int ret;
/* open/create the sqlite database */
ret = sqlite3_open(path.c_str(), &db);
if (ret != SQLITE_OK) {
const std::string utf8 = path.ToUTF8();
throw SqliteError(db, ret,
("Failed to open sqlite database '" +
utf8 + "'").c_str());
}
/* create the table and index */
ret = sqlite3_exec(db, sticker_sql_create,
@@ -123,8 +114,6 @@ StickerDatabase::~StickerDatabase() noexcept
sqlite3_finalize(stmt[i]);
}
sqlite3_close(db);
}
std::string