droplet 1.1.0
A multipurpose Discord bot with the hacker in mind
Loading...
Searching...
No Matches
Database Class Reference

#include <Database.hpp>

Collaboration diagram for Database:

Public Member Functions

 Database ()=delete
 

Static Public Member Functions

static auto connect (const std::string &db_name, const std::string &user, const std::string &password, const std::string &host, const std::string &port) -> bool
 connect to a postgres database
 
static auto connect (const std::string &connection_string) -> bool
 connect to a postgres database
 
static auto hasConnection () noexcept -> bool
 checks if the database has an active connection
 
static auto reconnect () noexcept -> void
 reconnects to the database server if the connection was lost
 
static auto disconnect () noexcept -> void
 disconnect from a postgres database
 
static auto getConnection () noexcept -> pqxx::connection *
 returns the database connection. Reconnects if the Database has no active connection
 

Constructor & Destructor Documentation

◆ Database()

Database::Database ( )
delete

Member Function Documentation

◆ connect() [1/2]

bool Database::connect ( const std::string & connection_string) -> bool
static

connect to a postgres database

Parameters
connection_stringconnection string used to connect to the database
Returns
returns a bool if the connection was successful

◆ connect() [2/2]

bool Database::connect ( const std::string & db_name,
const std::string & user,
const std::string & password,
const std::string & host,
const std::string & port ) -> bool
static

connect to a postgres database

Parameters
db_namename of the database
userdatabase user that will be used for the log in
passwordthe password that will be used to log in
hostthe ip or domain of the database server
portthe port the database service is listening on
Returns
returns a bool if the connection was successful

◆ disconnect()

void Database::disconnect ( ) -> void
staticnoexcept

disconnect from a postgres database

Parameters
connection_stringconnection string used to connect to the database
Returns
returns a bool if the connection was successful

◆ getConnection()

pqxx::connection * Database::getConnection ( ) -> pqxx::connection*
staticnoexcept

returns the database connection. Reconnects if the Database has no active connection

Returns
the active database connection as pqxx::connection pointer

◆ hasConnection()

bool Database::hasConnection ( ) -> bool
staticnoexcept

checks if the database has an active connection

Returns
returns true if the database is connected, false otherwise

◆ reconnect()

void Database::reconnect ( ) -> void
staticnoexcept

reconnects to the database server if the connection was lost

Returns
doesn't return anything

The documentation for this class was generated from the following files: