2020-11-28 14:18:58 +01:00
|
|
|
#ifndef PGSQL_CONNECTION
|
|
|
|
#define PGSQL_CONNECTION
|
|
|
|
|
2020-12-01 14:53:32 +01:00
|
|
|
#include "core/database.h"
|
|
|
|
#include "core/database_manager.h"
|
|
|
|
|
2020-11-28 14:18:58 +01:00
|
|
|
//Brynet has it aswell, and because of using namespace it is defined here aswell
|
|
|
|
//later this will be fixed better
|
|
|
|
//#ifdef IS_NUM
|
|
|
|
//#undef IS_NUM
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
#include <libpq-fe.h>
|
|
|
|
|
2020-12-01 14:56:05 +01:00
|
|
|
class PGSQLDatabase : public Database {
|
2020-12-01 14:53:32 +01:00
|
|
|
public:
|
|
|
|
static Database *_creation_func() {
|
2020-12-01 14:56:05 +01:00
|
|
|
return new PGSQLDatabase();
|
2020-12-01 14:53:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void _register() {
|
2020-12-01 14:56:05 +01:00
|
|
|
DatabaseManager::_register_db_creation_func("pgsql", PGSQLDatabase::_creation_func);
|
2020-12-01 14:53:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void _unregister() {
|
|
|
|
DatabaseManager::_unregister_db_creation_func("pgsql");
|
|
|
|
}
|
|
|
|
|
2020-12-01 14:56:05 +01:00
|
|
|
PGSQLDatabase() : Database() {
|
2020-12-01 14:53:32 +01:00
|
|
|
conn = PQconnectStart("");
|
|
|
|
}
|
2020-12-01 14:56:05 +01:00
|
|
|
~PGSQLDatabase() {
|
2020-12-01 14:53:32 +01:00
|
|
|
PQfinish(conn);
|
|
|
|
}
|
|
|
|
|
|
|
|
PGconn *conn;
|
2020-11-28 14:18:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//#undef IS_NUM
|
|
|
|
|
|
|
|
#endif
|