summaryrefslogtreecommitdiff
path: root/src/database/index.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-12-16 16:32:32 +0100
committerlouiz’ <louiz@louiz.org>2017-12-16 16:32:32 +0100
commit2c4016a4898a050c7f6ebd1843b265e209da1704 (patch)
treeb6c57d4fa446fe588cac6999c498dc1d7587dd9e /src/database/index.hpp
parentaaa9de8fe2c67b67310b7ba78c607bddbf4b25bf (diff)
parentb1f850b6395610c738a8e58abcdf2abfca3edd4e (diff)
downloadbiboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.gz
biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.bz2
biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.xz
biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.zip
Merge branch 'postgresql' into 'master'
Add postgresql support Closes #3237 See merge request louiz/biboumi!18
Diffstat (limited to 'src/database/index.hpp')
-rw-r--r--src/database/index.hpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/database/index.hpp b/src/database/index.hpp
index 5924779..30766ab 100644
--- a/src/database/index.hpp
+++ b/src/database/index.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <sqlite3.h>
+#include <database/engine.hpp>
#include <string>
#include <tuple>
@@ -25,18 +25,14 @@ add_column_name(std::string& out)
}
template <typename... Columns>
-void create_index(sqlite3* db, const std::string& name, const std::string& table)
+void create_index(DatabaseEngine& db, const std::string& name, const std::string& table)
{
- std::string res{"CREATE INDEX IF NOT EXISTS "};
- res += name + " ON " + table + "(";
- add_column_name<0, Columns...>(res);
- res += ")";
+ std::string query{"CREATE INDEX IF NOT EXISTS "};
+ query += name + " ON " + table + "(";
+ add_column_name<0, Columns...>(query);
+ query += ")";
- char* error;
- const auto result = sqlite3_exec(db, res.data(), nullptr, nullptr, &error);
- if (result != SQLITE_OK)
- {
- log_error("Error executing query: ", error);
- sqlite3_free(error);
- }
+ auto result = db.raw_exec(query);
+ if (std::get<0>(result) == false)
+ log_error("Error executing query: ", std::get<1>(result));
}