1
0
forked from blue/pica
pica/database/mysql/mysql.h

40 lines
993 B
C
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-12-07 20:32:43 +00:00
#pragma once
#include <stdexcept>
#include <filesystem>
2023-12-11 23:29:55 +00:00
#include <optional>
2023-12-07 20:32:43 +00:00
#include <mysql.h>
#include "database/dbinterface.h"
#include "utils/helpers.h"
2023-12-07 20:32:43 +00:00
class MySQL : public DBInterface {
2023-12-08 22:26:16 +00:00
class Statement;
2023-12-07 20:32:43 +00:00
public:
MySQL();
~MySQL() override;
void connect(const std::string& path) override;
void disconnect() override;
void setCredentials(const std::string& login, const std::string& password) override;
void setDatabase(const std::string& database) override;
void migrate(uint8_t targetVersion) override;
2023-12-08 22:26:16 +00:00
uint8_t getVersion() override;
void setVersion(uint8_t version) override;
private:
void executeFile(const std::filesystem::path& relativePath);
2023-12-11 23:29:55 +00:00
static std::optional<std::string> getComment(std::string& string);
2023-12-07 20:32:43 +00:00
protected:
MYSQL connection;
std::string login;
std::string password;
std::string database;
};