libdballe 9.6
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
dballe::sql::Connection Class Referenceabstract
Inheritance diagram for dballe::sql::Connection:
dballe::sql::MySQLConnection dballe::sql::PostgreSQLConnection dballe::sql::SQLiteConnection

Public Member Functions

const std::string & get_url () const
 
virtual std::unique_ptr< Transactiontransaction (bool readonly=false)=0
 Begin a transaction.
 
virtual bool has_table (const std::string &name)=0
 Check if the database contains a table.
 
virtual std::string get_setting (const std::string &key)=0
 Get a value from the settings table.
 
virtual void set_setting (const std::string &key, const std::string &value)=0
 Set a value in the settings table.
 
virtual void drop_settings ()=0
 Drop the settings table.
 
virtual void add_datetime (Querybuf &qb, const Datetime &dt) const
 Format a datetime and add it to the querybuf.
 
virtual void execute (const std::string &query)=0
 Execute a query without reading its results.
 
virtual void explain (const std::string &query, FILE *out)=0
 Format and print the EXPLAIN output for the query to the given file.
 

Static Public Member Functions

static std::shared_ptr< Connectioncreate (const DBConnectOptions &options)
 Create a new connection from a URL.
 

Public Attributes

ServerType server_type
 Type of SQL server we are connected to.
 

Protected Member Functions

void register_atfork ()
 Register this connection to be notified in case of fork()-ing.
 
virtual void fork_prepare ()
 
virtual void fork_parent ()
 
virtual void fork_child ()
 

Protected Attributes

std::string url
 

Member Function Documentation

◆ drop_settings()

virtual void dballe::sql::Connection::drop_settings ( )
pure virtual

◆ execute()

virtual void dballe::sql::Connection::execute ( const std::string &  query)
pure virtual

Execute a query without reading its results.

Implemented in dballe::sql::MySQLConnection, dballe::sql::PostgreSQLConnection, and dballe::sql::SQLiteConnection.

◆ explain()

virtual void dballe::sql::Connection::explain ( const std::string &  query,
FILE *  out 
)
pure virtual

Format and print the EXPLAIN output for the query to the given file.

Implemented in dballe::sql::MySQLConnection, dballe::sql::PostgreSQLConnection, and dballe::sql::SQLiteConnection.

◆ get_setting()

virtual std::string dballe::sql::Connection::get_setting ( const std::string &  key)
pure virtual

Get a value from the settings table.

Returns the empty string if the table does not exist.

Implemented in dballe::sql::MySQLConnection, dballe::sql::PostgreSQLConnection, and dballe::sql::SQLiteConnection.

◆ has_table()

virtual bool dballe::sql::Connection::has_table ( const std::string &  name)
pure virtual

Check if the database contains a table.

Implemented in dballe::sql::MySQLConnection, dballe::sql::PostgreSQLConnection, and dballe::sql::SQLiteConnection.

◆ set_setting()

virtual void dballe::sql::Connection::set_setting ( const std::string &  key,
const std::string &  value 
)
pure virtual

Set a value in the settings table.

The table is created if it does not exist.

Implemented in dballe::sql::MySQLConnection, dballe::sql::PostgreSQLConnection, and dballe::sql::SQLiteConnection.

◆ transaction()

virtual std::unique_ptr< Transaction > dballe::sql::Connection::transaction ( bool  readonly = false)
pure virtual

Begin a transaction.

The transaction will be controller by the returned Transaction object, and will end when its destuctor is called.

Implemented in dballe::sql::MySQLConnection, dballe::sql::PostgreSQLConnection, and dballe::sql::SQLiteConnection.

Member Data Documentation

◆ server_type

ServerType dballe::sql::Connection::server_type

Type of SQL server we are connected to.

Use this to tell which SQL dialect to use, in case standard SQL behaviour is not enough


The documentation for this class was generated from the following file: