libdballe
7.7
|
Database connection. More...
#include <internals.h>
Public Member Functions | |
MySQLConnection (const MySQLConnection &)=delete | |
MySQLConnection (const MySQLConnection &&)=delete | |
MySQLConnection & | operator= (const MySQLConnection &)=delete |
MySQLConnection & | operator= (const MySQLConnection &&)=delete |
operator MYSQL * () | |
void | open_url (const std::string &url) |
void | open_test () |
std::string | escape (const char *str) |
Escape a C string. | |
std::string | escape (const std::string &str) |
Escape a string. | |
void | exec_no_data_nothrow (const char *query) noexcept |
Run a query throwing no exceptions, warning on stderr if it is not successful or if it gives a nonempty result. | |
void | exec_no_data (const char *query) |
void | exec_no_data (const std::string &query) |
mysql::Result | exec_store (const char *query) |
mysql::Result | exec_store (const std::string &query) |
void | exec_use (const char *query, std::function< void(const mysql::Row &)> dest) |
void | exec_use (const std::string &query, std::function< void(const mysql::Row &)> dest) |
std::unique_ptr< Transaction > | transaction () override |
Begin a transaction. More... | |
bool | has_table (const std::string &name) override |
Check if the database contains a table. | |
std::string | get_setting (const std::string &key) override |
Get a value from the settings table. More... | |
void | set_setting (const std::string &key, const std::string &value) override |
Set a value in the settings table. More... | |
void | drop_settings () override |
Drop the settings table. | |
void | drop_table_if_exists (const char *name) |
Delete a table in the database if it exists, otherwise do nothing. | |
int | get_last_insert_id () |
Return LAST_INSERT_ID or LAST_INSER_ROWID or whatever is appropriate for the current database, if supported. More... | |
![]() | |
const std::string & | get_url () const |
virtual void | add_datetime (Querybuf &qb, const Datetime &dt) const |
Format a datetime and add it to the querybuf. | |
Protected Member Functions | |
void | send_result (mysql::Result &&res, std::function< void(const mysql::Row &)> dest) |
void | init_after_connect () |
void | open (const mysql::ConnectInfo &info) |
Protected Attributes | |
MYSQL * | db = nullptr |
Database connection. | |
![]() | |
std::string | url |
Additional Inherited Members | |
![]() | |
static std::unique_ptr< Connection > | create_from_url (const char *url) |
Create a new connection from a URL. | |
static std::unique_ptr< Connection > | create_from_url (const std::string &url) |
Create a new connection from a URL. | |
![]() | |
ServerType | server_type |
Type of SQL server we are connected to. More... | |
Database connection.
int dballe::db::MySQLConnection::get_last_insert_id | ( | ) |
Return LAST_INSERT_ID or LAST_INSER_ROWID or whatever is appropriate for the current database, if supported.
If not supported, an exception is thrown.
|
overridevirtual |
Get a value from the settings table.
Returns the empty string if the table does not exist.
Implements dballe::db::Connection.
|
overridevirtual |
Set a value in the settings table.
The table is created if it does not exist.
Implements dballe::db::Connection.
|
overridevirtual |
Begin a transaction.
The transaction will be controller by the returned Transaction object, and will end when its destuctor is called.
Implements dballe::db::Connection.