|
MantisBase v0.3.4
|
Database connection and session management. More...
#include <database.h>
Public Member Functions | |
| Database () | |
| Construct database instance. | |
| ~Database () | |
| Destructor (disconnects from database). | |
| bool | connect (const std::string &conn_str) |
| Connect to database and initialize connection pool. | |
| const std::string & | connectionStr () const |
| void | disconnect () |
| Close all database connections and destroy connection pool. | |
| bool | createSysTables () const |
| Create system tables (mb_tables, mb_admins, etc.). | |
| std::shared_ptr< soci::session > | session () const |
| Get a database session from the connection pool. | |
| soci::connection_pool & | connectionPool () const |
| Get access to the underlying connection pool. | |
| bool | isConnected () const |
| Check if database is connected. | |
Database connection and session management.
Handles database connections, connection pooling, and provides session management for executing queries. Supports SQLite (default) and PostgreSQL.
| mb::Database::Database | ( | ) |
Construct database instance.
| mb::Database::~Database | ( | ) |
Destructor (disconnects from database).
| bool mb::Database::connect | ( | const std::string & | conn_str | ) |
Connect to database and initialize connection pool.
| conn_str | Connection string (format depends on database type)
|
| soci::connection_pool & mb::Database::connectionPool | ( | ) | const |
Get access to the underlying connection pool.
| const std::string & mb::Database::connectionStr | ( | ) | const |
| bool mb::Database::createSysTables | ( | ) | const |
Create system tables (mb_tables, mb_admins, etc.).
| void mb::Database::disconnect | ( | ) |
Close all database connections and destroy connection pool.
| bool mb::Database::isConnected | ( | ) | const |
Check if database is connected.
| std::shared_ptr< soci::session > mb::Database::session | ( | ) | const |
Get a database session from the connection pool.