Database header
This commit is contained in:
22
Database.cpp
22
Database.cpp
@@ -1,4 +1,26 @@
|
||||
#include "Database.hpp"
|
||||
#include "Config.hpp"
|
||||
|
||||
Database::Database(){
|
||||
Config conf("config.txt");
|
||||
std::ostringstream pgsqlConnectingString;
|
||||
|
||||
pgsqlConnectingString
|
||||
<< " host=" << conf.getValue("db_host")
|
||||
<< " dbname=" << conf.getValue("db_name")
|
||||
<< " user=" << conf.getValue("db_user")
|
||||
<< " password=" << conf.getValue("db_pass");
|
||||
|
||||
dbconn = new pqxx::connection(pgsqlConnectingString.str());
|
||||
}
|
||||
|
||||
pqxx::result Database::execute(std::string cmd){
|
||||
pqxx::work w(*dbconn);
|
||||
pqxx::result r(w.exec(cmd));
|
||||
w.commit();
|
||||
return r;
|
||||
}
|
||||
|
||||
void Database::disconnect(){
|
||||
dbconn->close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user