Add postgresql support

This commit is contained in:
louiz’
2017-12-02 20:08:47 +01:00
parent 5b27cee972
commit 0168b96b79
32 changed files with 1008 additions and 342 deletions
+5 -7
View File
@@ -2,6 +2,7 @@
#include <database/query.hpp>
#include <database/table.hpp>
#include <database/statement.hpp>
#include <string>
@@ -15,20 +16,17 @@ struct CountQuery: public Query
this->body += std::move(name);
}
int64_t execute(sqlite3* db)
int64_t execute(DatabaseEngine& db)
{
auto statement = this->prepare(db);
auto statement = db.prepare(this->body);
int64_t res = 0;
if (sqlite3_step(statement.get()) == SQLITE_ROW)
res = sqlite3_column_int64(statement.get(), 0);
if (statement->step() != StepResult::Error)
res = statement->get_column_int64(0);
else
{
log_error("Count request didn’t return a result");
return 0;
}
if (sqlite3_step(statement.get()) != SQLITE_DONE)
log_warning("Count request returned more than one result.");
return res;
}
};