#include <Database.hpp>
|
| static bool | connect (const std::string &db_name, const std::string &user, const std::string &password, const std::string &host, const std::string &port) |
| | connect to a postgres database
|
| static bool | connect (const std::string &connection_string) |
| | connect to a postgres database
|
| static bool | hasConnection () noexcept |
| | checks if the database has an active connection
|
| static void | reconnect () noexcept |
| | reconnects to the database server if the connection was lost
|
| static void | disconnect () noexcept |
| | disconnect from a postgres database
|
| static NativeDatabase::Connection * | getConnection () noexcept |
| | returns the database connection. Reconnects if the Database has no active connection
|
This is a Database class to manage the connection to a Database it is a wrapper around a Platform specific Database connection for now this is a Postgres Database using the pqxx Library
◆ Database()
◆ connect() [1/2]
| bool Database::connect |
( |
const std::string & | connection_string | ) |
|
|
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 ) |
|
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 |
( |
| ) |
|
|
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()
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 |
( |
| ) |
|
|
staticnoexcept |
checks if the database has an active connection
- Returns
- returns true if the database is connected, false otherwise
◆ reconnect()
| void Database::reconnect |
( |
| ) |
|
|
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: