Darwin Neuroevolution Framework
Public Member Functions | List of all members
db::Connection Class Reference

A very simple relational database abstraction on top of Sqlite. More...

#include <database.h>

Inheritance diagram for db::Connection:
core::NonCopyable

Public Member Functions

 Connection (const string &filename, OpenMode open_mode, int busy_wait_ms=500)
 Opens a Sqlite connection.
 
void beginTransaction (TransactionOption option=TransactionOption::Deferred)
 Starts a transaction.
 
void commit ()
 Commits the current transaction.
 
void rollback ()
 Aborts the current transaction.
 
RowId lastInsertRowId () const
 Returns the ID of the last inserted row with this connection.
 
template<class... RESULTS, class... PARAMS>
ResultSet< RESULTS... > exec (const string &sql_statement, PARAMS &&... params)
 Executes the specified Sqlite statement and returns the results as a ResultSet. More...
 

Detailed Description

A very simple relational database abstraction on top of Sqlite.

Member Function Documentation

◆ exec()

template<class... RESULTS, class... PARAMS>
ResultSet<RESULTS...> db::Connection::exec ( const string &  sql_statement,
PARAMS &&...  params 
)
inline

Executes the specified Sqlite statement and returns the results as a ResultSet.

It supports parameterized queries: each instance of ? is substituted by the corresponding parameter value:

exec("insert into t(name, value) values(?, ?)", "Darwin", 100);

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