d/j2: Some work on the SQL editors (#2771)

This commit is contained in:
Tyler Wilding
2023-06-25 15:51:46 -05:00
committed by GitHub
parent 25e7c9bc5d
commit 10934f6746
104 changed files with 47021 additions and 21943 deletions
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "third-party/sqlite3/sqlite3.h"
// Just a simple wrapper around the raw C types from sqlite3
// takes care of all the relevant memory freeing and such for you (hopefully)
namespace sqlite {
struct SQLite3DatabaseDeleter {
void operator()(sqlite3* db) const {
if (db) {
sqlite3_close(db);
}
}
};
struct GenericResponse {
std::vector<std::vector<std::string>> rows;
};
class SQLiteDatabase {
public:
SQLiteDatabase() = default;
bool is_open() const { return m_db.has_value(); }
bool open_db(const std::string& path);
GenericResponse run_query(const std::string& sql);
private:
std::optional<std::shared_ptr<sqlite3>> m_db;
};
} // namespace sqlite