The connection class represents a connection to a database.
More...
#include <connection.hpp>
|
template<class T > |
class | query |
|
The connection class represents a connection to a database.
◆ connection() [1/4]
matador::connection::connection |
( |
const std::string & |
dns | ) |
|
|
explicit |
Creates a database connection from a connection string.
- Parameters
-
dns | The database connection string |
◆ connection() [2/4]
matador::connection::connection |
( |
const std::string & |
dns, |
|
|
std::shared_ptr< basic_sql_logger > |
sql_logger |
|
) |
| |
Creates a database connection from a connection string.
- Parameters
-
dns | The database connection string |
sql_logger | The logger handler to write sql log messages to |
◆ connection() [3/4]
matador::connection::connection |
( |
const connection & |
x | ) |
|
Copies a given connection
- Parameters
-
◆ connection() [4/4]
matador::connection::connection |
( |
connection && |
x | ) |
|
|
noexcept |
Copy moves a given connection
- Parameters
-
x | The connection to copy move |
◆ client_version()
version matador::connection::client_version |
( |
| ) |
const |
Return the version string of the current database type.
- Returns
- Version string of the current database type
◆ connect() [1/2]
void matador::connection::connect |
( |
| ) |
|
Opens the sql.
Opens the sql. If sql couldn't be opened an exception is thrown.
◆ connect() [2/2]
void matador::connection::connect |
( |
const std::string & |
dns | ) |
|
Opens the sql for the given dns.
Opens the sql. If sql couldn't be opened an exception is thrown.
◆ describe()
std::vector< field > matador::connection::describe |
( |
const std::string & |
table | ) |
const |
Retrieve a field description list of a table.
- Parameters
-
table | The name of the requested table |
- Returns
- A list of fields
◆ dialect()
Get the underlying sql dialect object.
- Returns
- Sql dialect object.
◆ disable_log()
void matador::connection::disable_log |
( |
| ) |
|
Disable console log of sql statements
◆ disconnect()
void matador::connection::disconnect |
( |
| ) |
|
Closes the sql.
Closes the sql.
◆ enable_log()
void matador::connection::enable_log |
( |
| ) |
|
Enable console log of sql statements
◆ execute()
void matador::connection::execute |
( |
const std::string & |
stmt | ) |
|
|
inline |
Execute a sql string statement with retrieving any result.
- Parameters
-
stmt | The statement to be executed |
◆ exists()
bool matador::connection::exists |
( |
const std::string & |
table_name | ) |
const |
returns true if a table with given name exists.
- Parameters
-
table_name | Name of table to be checked |
- Returns
- True if table exists.
◆ is_connected()
bool matador::connection::is_connected |
( |
| ) |
const |
Returns true if sql is open.
Returns true if sql is open
- Returns
- True on open sql.
◆ is_log_enabled()
bool matador::connection::is_log_enabled |
( |
| ) |
const |
Returns true if logging is enabled.
- Returns
- True if logging is enabled
◆ is_valid()
bool matador::connection::is_valid |
( |
| ) |
const |
Returns true if connection is valid.
Returns true if connection is valid, i.e. the database connection string is set correctly
- Returns
- True if connection is valid
◆ operator=() [1/2]
Assigns moves from the given connection
- Parameters
-
x | The connection to assign move |
- Returns
- The reference to the assigned connection
◆ operator=() [2/2]
Assigns from the given connection
- Parameters
-
x | The connection to assign |
- Returns
- The reference to the assigned connection
◆ reconnect()
void matador::connection::reconnect |
( |
| ) |
|
Reconnect to the database. This means to close and open the connection.
◆ server_version()
version matador::connection::server_version |
( |
| ) |
const |
Return the version string of the current database type.
- Returns
- Version string of the current database type
◆ type()
std::string matador::connection::type |
( |
| ) |
const |
Return the database type of the connection.
Returns the database type of the connection which is currently one of
- mssql
- mysql
- sqlite
- postgressql
- Returns
- The database type string
The documentation for this class was generated from the following file:
- matador/sql/connection.hpp