![]() |
Mantis App v0.1.13
|
Database Management Class. More...
#include <database.h>
Public Member Functions | |
DatabaseUnit () | |
bool | connect (DbType backend, const std::string &conn_str) |
Initializes the connection pool & connects to specific database. | |
void | disconnect () const |
CLose all database connections and destroy connection pools. | |
void | migrate () const |
Run database migrations, creates the default system tables. | |
std::shared_ptr< soci::session > | session () const |
Get access to a session from the pool. | |
soci::connection_pool & | connectionPool () const |
bool | isConnected () const |
Check if the database is connected. | |
Static Public Member Functions | |
static std::string | tmToISODate (const std::tm &t) |
Convert c++ std::tm date/time value to ISO formatted string. | |
Public Attributes | |
const std::string | __class_name__ = "mantis::DatabaseUnit" |
Database Management Class.
The class handles database connections, pooling and sessions.
mantis::DatabaseUnit::DatabaseUnit | ( | ) |
bool mantis::DatabaseUnit::connect | ( | DbType | backend, |
const std::string & | conn_str | ||
) |
Initializes the connection pool & connects to specific database.
backend | Database Type selected [SQLITE, PSQL, MYSQL, etc.] |
conn_str | Connection string for database containing username, password, etc. Not used for SQLite dbs. |
soci::connection_pool & mantis::DatabaseUnit::connectionPool | ( | ) | const |
Access to the underlying soci connection_pool instance
void mantis::DatabaseUnit::disconnect | ( | ) | const |
CLose all database connections and destroy connection pools.
bool mantis::DatabaseUnit::isConnected | ( | ) | const |
Check if the database is connected.
void mantis::DatabaseUnit::migrate | ( | ) | const |
Run database migrations, creates the default system tables.
std::shared_ptr< soci::session > mantis::DatabaseUnit::session | ( | ) | const |
Get access to a session from the pool.
|
static |
Convert c++ std::tm date/time value to ISO formatted string.
t | std::tm value |
const std::string mantis::DatabaseUnit::__class_name__ = "mantis::DatabaseUnit" |