62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#ifndef QUERY_POSTGRES_CONNECTION_HPP
|
|
#define QUERY_POSTGRES_CONNECTION_HPP
|
|
|
|
#ifdef _MSC_VER
|
|
#ifdef matador_mysql_EXPORTS
|
|
#define MATADOR_MYSQL_API __declspec(dllexport)
|
|
#else
|
|
#define MATADOR_MYSQL_API __declspec(dllimport)
|
|
#endif
|
|
#pragma warning(disable: 4355)
|
|
#else
|
|
#define MATADOR_MYSQL_API
|
|
#endif
|
|
|
|
#include "matador/sql/connection_impl.hpp"
|
|
|
|
#include <unordered_map>
|
|
|
|
#ifdef _MSC_VER
|
|
#include <mysql.h>
|
|
#else
|
|
#include <mysql/mysql.h>
|
|
#endif
|
|
|
|
namespace matador::backends::mysql {
|
|
|
|
class mysql_connection : public matador::sql::connection_impl
|
|
{
|
|
public:
|
|
explicit mysql_connection(const sql::connection_info &info);
|
|
void open() override;
|
|
void close() override;
|
|
bool is_open() override;
|
|
|
|
std::unique_ptr<sql::query_result_impl> fetch(const std::string &stmt) override;
|
|
std::unique_ptr<sql::statement_impl> prepare(sql::query_context context) override;
|
|
|
|
size_t execute(const std::string &stmt) override;
|
|
|
|
sql::record describe(const std::string& table) override;
|
|
|
|
bool exists(const std::string &schema_name, const std::string &table_name) override;
|
|
|
|
private:
|
|
mutable std::unique_ptr<MYSQL> mysql_;
|
|
|
|
using string_to_int_map = std::unordered_map<std::string, unsigned long>;
|
|
|
|
static string_to_int_map statement_name_map_;
|
|
};
|
|
|
|
}
|
|
|
|
extern "C"
|
|
{
|
|
MATADOR_MYSQL_API matador::sql::connection_impl* create_database(const matador::sql::connection_info &info);
|
|
|
|
MATADOR_MYSQL_API void destroy_database(matador::sql::connection_impl *db);
|
|
}
|
|
|
|
#endif //QUERY_POSTGRES_CONNECTION_HPP
|