added postgres backend
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#ifndef QUERY_POSTGRES_CONNECTION_HPP
|
||||
#define QUERY_POSTGRES_CONNECTION_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef matador_postgres_EXPORTS
|
||||
#define MATADOR_POSTGRES_API __declspec(dllexport)
|
||||
#else
|
||||
#define MATADOR_POSTGRES_API __declspec(dllimport)
|
||||
#endif
|
||||
#pragma warning(disable: 4355)
|
||||
#else
|
||||
#define MATADOR_POSTGRES_API
|
||||
#endif
|
||||
|
||||
#include "matador/sql/connection_impl.hpp"
|
||||
|
||||
#include <libpq-fe.h>
|
||||
|
||||
namespace matador::backends::postgres {
|
||||
|
||||
class postgres_connection : public matador::sql::connection_impl
|
||||
{
|
||||
public:
|
||||
explicit postgres_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;
|
||||
void prepare(const std::string &stmt) override;
|
||||
|
||||
size_t execute(const std::string &stmt) override;
|
||||
|
||||
sql::record describe(const std::string& table) override;
|
||||
|
||||
bool exists(const std::string &table_name) override;
|
||||
|
||||
private:
|
||||
PGconn *conn_{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
MATADOR_POSTGRES_API matador::sql::connection_impl* create_database(const matador::sql::connection_info &info);
|
||||
|
||||
MATADOR_POSTGRES_API void destroy_database(matador::sql::connection_impl *db);
|
||||
}
|
||||
|
||||
#endif //QUERY_POSTGRES_CONNECTION_HPP
|
||||
Reference in New Issue
Block a user