Little work on the sqlite database backend.

This commit is contained in:
Relintai 2021-05-01 20:31:52 +02:00
parent 06cd3e0f6b
commit ec8de94827
4 changed files with 64 additions and 13 deletions

View File

@ -13,3 +13,28 @@ void SQLite3Database::_register() {
void SQLite3Database::_unregister() { void SQLite3Database::_unregister() {
DatabaseManager::_unregister_db_creation_func("sqlite"); DatabaseManager::_unregister_db_creation_func("sqlite");
} }
void SQLite3Database::connect(const std::string &connection_str) {
int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
if (ret != SQLITE_OK) {
printf("SQLITE3 multithreading is not supported!\n");
}
ret = sqlite3_open(connection_str.c_str(), &conn);
}
QueryResult *SQLite3Database::query(const std::string &query) {
return nullptr;
}
void SQLite3Database::query_run(const std::string &query) {
}
SQLite3Database::SQLite3Database() :
Database() {
}
SQLite3Database::~SQLite3Database() {
if (conn)
sqlite3_close(conn);
}

View File

@ -19,20 +19,12 @@ public:
static void _register(); static void _register();
static void _unregister(); static void _unregister();
SQLite3Database() : void connect(const std::string &connection_str);
Database() { QueryResult *query(const std::string &query);
void query_run(const std::string &query);
int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); SQLite3Database();
if (ret != SQLITE_OK) { ~SQLite3Database();
printf("SQLITE3 multithreading is not supported!\n");
}
ret = sqlite3_open("", &conn);
}
~SQLite3Database() {
sqlite3_close(conn);
}
sqlite3 *conn; sqlite3 *conn;
}; };

View File

@ -0,0 +1,17 @@
#include "sqlite3_query_result.h"
#include <cstdio>
bool Sqlite3QueryResult::next_row() {
return false;
}
const char* Sqlite3QueryResult::get_cell(const int index) {
return nullptr;
}
Sqlite3QueryResult::Sqlite3QueryResult() : QueryResult() {
}
Sqlite3QueryResult::~Sqlite3QueryResult() {
}

View File

@ -0,0 +1,17 @@
#ifndef MYSQL_QUERY_RESULT_H
#define MYSQL_QUERY_RESULT_H
#include "core/query_result.h"
#include <sqlite3.h>
class Sqlite3QueryResult : public QueryResult {
public:
bool next_row();
const char* get_cell(const int index);
Sqlite3QueryResult();
~Sqlite3QueryResult();
};
#endif