ark::database::AbstractDatabaseConnection

Defined in header “ark/database/connection.hh”.


This is an abstract database connection, while tries to abstract the underlying connection protocol and specifics from the user. This allows us to support different database backends.

Methods

  • ~AbstractDatabaseConnection()
    Virtual destructor, for cleanup.

  • void begin_transaction()
    Begins a new transaction on this connection. When this is done, all queries are batched into a single transaction. When not done, each execute_query() gets its own transaction.

  • void end_transaction()
    Ends a transaction on this connection. Commits all outstanding queries.

  • void rollback_transaction()
    Rollback a transaction on this connection. All completed work is aborted.

  • void lock_table(const std::string & table_name, const std::optional< std::chrono::seconds > & timeout)
    Locks a table. Executes SQL to lock the given table with the given timeout.

  • AbstractDatabaseResultPtr execute_query(const std::string & query, std::span< std::string > params)
    Virtual classes should implement this in order to handle executing SQL statements against their chosen backend.

  • AbstractDatabaseResultPtr execute(const std::string & query, Args &&… args)
    Executes the given query. The ‘args’ are a list of values that will be forwarded to the underlying database engine. They must be in order, based on your query.

  • void execute_and_step(const std::string & query, Args &&… args)
    Executes the given query, and does an immediate step. A convenience method.