summaryrefslogtreecommitdiff
path: root/src/sticker
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-04-25 12:10:12 +0200
committerMax Kellermann <max@musicpd.org>2019-04-25 12:10:12 +0200
commita6dc1ab0a9224a4c1dd6b8837a66081df4ce6868 (patch)
treea87f1015c8c08cc36b16b46ac7f3635cd20708aa /src/sticker
parent77c9081f781c4afd975f58b549ed47bd35375ce2 (diff)
lib/sqlite/Database: wrapper for `sqlite3*`
Diffstat (limited to 'src/sticker')
-rw-r--r--src/sticker/Database.cxx13
-rw-r--r--src/sticker/Database.hxx3
2 files changed, 3 insertions, 13 deletions
diff --git a/src/sticker/Database.cxx b/src/sticker/Database.cxx
index 302ba3e3f..c90cbdcf7 100644
--- a/src/sticker/Database.cxx
+++ b/src/sticker/Database.cxx
@@ -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
diff --git a/src/sticker/Database.hxx b/src/sticker/Database.hxx
index efc94b3ca..61a908d81 100644
--- a/src/sticker/Database.hxx
+++ b/src/sticker/Database.hxx
@@ -43,6 +43,7 @@
#define MPD_STICKER_DATABASE_HXX
#include "Match.hxx"
+#include "lib/sqlite/Database.hxx"
#include "util/Compiler.h"
#include <sqlite3.h>
@@ -69,7 +70,7 @@ class StickerDatabase {
SQL_COUNT
};
- sqlite3 *db;
+ Sqlite::Database db;
sqlite3_stmt *stmt[SQL_COUNT];
public: