#include <Database.hpp>
|
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
|
|
◆ Database()
◆ connect() [1/2]
bool Database::connect |
( |
const std::string & | connection_string | ) |
-> bool |
|
staticnodiscard |
connect to a postgres database
- Parameters
-
connection_string | connection 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 |
|
staticnodiscard |
connect to a postgres database
- Parameters
-
db_name | name of the database |
user | database user that will be used for the log in |
password | the password that will be used to log in |
host | the ip or domain of the database server |
port | the 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_string | connection 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: