AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::sql::Connection Class Referenceabstract

SQL connection virtual class. More...

#include <connection.hpp>

Inheritance diagram for anch::sql::Connection:
Collaboration diagram for anch::sql::Connection:

Classes

struct  CachedStatement

Public Member Functions

 Connection (std::size_t statementCacheSize=DEFAULT_STATEMENT_CACHE_SIZE)
 Connection (const Connection &)=delete
virtual ~Connection () noexcept
void startTransaction ()
void begin ()
void commit ()
void rollback ()
void release () noexcept
PreparedStatement & prepareStatement (const std::string &query)
ResultSet * query (const std::string &query)
void queryMapRow (const std::string &sqlQuery, std::function< void(ResultSet &)> rowMapper)
void queryExtract (const std::string &sqlQuery, std::function< void(ResultSet &)> resExtractor)
ResultSet * query (const std::string &query, const anch::sql::Parameters &parameters)
void queryMapRow (const std::string &query, std::function< void(ResultSet &)> rowMapper, const anch::sql::Parameters &parameters)
void queryExtract (const std::string &query, std::function< void(ResultSet &)> resExtractor, const anch::sql::Parameters &parameters)
uint64_t update (const std::string &query)
uint64_t update (const std::string &query, const anch::sql::Parameters &parameters)
template<typename T, typename Iterable>
uint64_t batchUpdate (const std::string &query, std::function< void(anch::sql::Parameters &, const T &)> mapper, const Iterable &values)
template<std::ranges::input_range Iterable>
requires anch::Described<std::ranges::range_value_t<Iterable>>
uint64_t batchUpdate (const std::string &query, const Iterable &values)
template<anch::Described T>
ResultSet * query (const std::string &query, const anch::sql::FieldsOf< T > &fields)
template<anch::Described T>
void queryMapRow (const std::string &query, std::function< void(ResultSet &)> rowMapper, const anch::sql::FieldsOf< T > &fields)
template<anch::Described T>
void queryExtract (const std::string &query, std::function< void(ResultSet &)> resExtractor, const anch::sql::FieldsOf< T > &fields)
template<anch::Described T>
uint64_t update (const std::string &query, const anch::sql::FieldsOf< T > &fields)
template<anch::sql::Row T>
std::vector< T > queryList (const std::string &query)
template<anch::sql::Row T>
std::optional< T > queryOne (const std::string &query)
template<anch::sql::Row T>
void queryEach (const std::string &query, std::function< void(T &&)> rowHandler)
template<anch::sql::Row T>
std::vector< T > queryList (const std::string &query, const anch::sql::Parameters &parameters)
template<anch::sql::Row T>
std::optional< T > queryOne (const std::string &query, const anch::sql::Parameters &parameters)
template<anch::sql::Row T>
void queryEach (const std::string &query, std::function< void(T &&)> rowHandler, const anch::sql::Parameters &parameters)
template<anch::sql::Row T, anch::Described U>
std::vector< T > queryList (const std::string &query, const anch::sql::FieldsOf< U > &fields)
template<anch::sql::Row T, anch::Described U>
std::optional< T > queryOne (const std::string &query, const anch::sql::FieldsOf< U > &fields)
template<anch::sql::Row T, anch::Described U>
void queryEach (const std::string &query, std::function< void(T &&)> rowHandler, const anch::sql::FieldsOf< U > &fields)
std::size_t getStatementCacheSize () const noexcept
void setStatementCacheSize (std::size_t size)
std::size_t getCachedStatementCount () const noexcept
bool isValid () const noexcept

Protected Member Functions

virtual ResultSet * executeQuery (const std::string &query)=0
virtual uint64_t executeUpdate (const std::string &query)=0
virtual void sendStartTransaction ()=0
virtual void sendCommit ()=0
virtual void sendRollback ()=0
virtual PreparedStatement * makePrepared (const std::string &query)=0
template<typename F>
auto guard (F &&func) -> decltype(func())
void onError (const SqlException &error) noexcept
void clearStatements () noexcept
virtual bool checkConnection () const noexcept
void setValid (bool valid) noexcept

Protected Attributes

bool _valid
bool _transaction
std::list< CachedStatement > _stmts
std::unordered_map< std::string_view, std::list< CachedStatement >::iterator > _stmtsIndex
std::size_t _stmtsMax

Friends

class PreparedStatement
class ResultSet

Detailed Description

SQL connection virtual class.

Abstract layer for SQL connections management.

Errors: every SqlException raised by the connection, its prepared statements and its result sets is reported to the connection. A fatal error (SqlException::isOK is false : connection lost, out of memory, protocol error, ...) invalidates the connection: isValid returns false and connection pools destroy it instead of reusing it. Other errors (syntax, constraint, ...) keep the connection valid.

Transactions: without startTransaction , each query is committed by the database (auto-commit mode). A transaction started with startTransaction is committed only by commit : a transaction which is not ended when the connection is released (returned to its pool or destroyed) is rolled back, with or without error.

Prepared statements: prepareStatement keeps the prepared statements in a bounded cache (least recently used statement first evicted, see setStatementCacheSize ). A statement is never evicted while one of its result sets is alive: the cache can then temporarily exceed its maximum size. An evicted statement is deallocated on the server side. A statement is not executed again while one of its result sets is alive (nested queries with the same SQL text): an other statement is prepared for the same query. A statement invalidated by the database (PostgreSQL: result type changed by a schema change) is prepared again.

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ Connection() [1/2]

anch::sql::Connection::Connection ( std::size_t statementCacheSize = DEFAULT_STATEMENT_CACHE_SIZE)
explicit

Connection constructor

Parameters
statementCacheSizethe maximum number of cached prepared statements (at least 1 )
Exceptions
SqlExceptioninvalid cache size

◆ Connection() [2/2]

anch::sql::Connection::Connection ( const Connection & )
delete

Prohibit Connection copy constructor

Here is the call graph for this function:

◆ ~Connection()

virtual anch::sql::Connection::~Connection ( )
virtualnoexcept

Connection destrcutor

Member Function Documentation

◆ batchUpdate() [1/2]

template<std::ranges::input_range Iterable>
requires anch::Described<std::ranges::range_value_t<Iterable>>
uint64_t anch::sql::Connection::batchUpdate ( const std::string & query,
const Iterable & values )

Execute batch prepared statement with described objects: the parameters of each object are its fields ( fieldsOf )

Parameters
querythe SQL query (with named parameters: :name )
valuesthe described objects
Returns
the number of affected rows
Exceptions
SqlExceptionany error (a parameter which is not a field is not bound: non fatal)
Since
0.3
Here is the call graph for this function:

◆ batchUpdate() [2/2]

template<typename T, typename Iterable>
uint64_t anch::sql::Connection::batchUpdate ( const std::string & query,
std::function< void(anch::sql::Parameters &, const T &)> mapper,
const Iterable & values )

Execute batch prepared statement

Parameters
querythe SQL query (with named parameters: :name )
mapperthe function which gives the parameters of a value (every parameter of the query has to be given for each value: parameters of the previous value are not reused)
valuesthe values as structure or class
Returns
the number of affected rows
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ begin()

void anch::sql::Connection::begin ( )

Alias for startTransaction

Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ checkConnection()

virtual bool anch::sql::Connection::checkConnection ( ) const
protectedvirtualnoexcept

Check driver connection status (called by isValid ; default to true )

Returns
true when the driver connection is usable, false otherwise
Since
0.2

Reimplemented in anch::sql::PostgreSQLConnection.

Here is the call graph for this function:

◆ clearStatements()

void anch::sql::Connection::clearStatements ( )
protectednoexcept

Delete every cached prepared statement without deallocating it on the server side.
Drivers which have to release statements before closing their connection call it in their destructor.

Since
0.2
Here is the call graph for this function:

◆ commit()

void anch::sql::Connection::commit ( )

Commit current SQL transaction.
If there is not transaction, this method does nothing.

Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ executeQuery()

virtual ResultSet * anch::sql::Connection::executeQuery ( const std::string & query)
protectedpure virtual

Execute SQL select query

Parameters
querythe SQL query to execute
Returns
the result set which has to be deleted after use
Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLConnection, anch::sql::PostgreSQLConnection, and anch::sql::SQLite3Connection.

Here is the call graph for this function:

◆ executeUpdate()

virtual uint64_t anch::sql::Connection::executeUpdate ( const std::string & query)
protectedpure virtual

Execute SQL update query

Parameters
querythe SQL query to execute
Returns
the result set which has to be deleted after use
Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLConnection, anch::sql::PostgreSQLConnection, and anch::sql::SQLite3Connection.

Here is the call graph for this function:

◆ getCachedStatementCount()

std::size_t anch::sql::Connection::getCachedStatementCount ( ) const
noexcept

Number of cached prepared statements getter

Returns
the number of cached prepared statements
Since
0.2
Here is the call graph for this function:

◆ getStatementCacheSize()

std::size_t anch::sql::Connection::getStatementCacheSize ( ) const
noexcept

Maximum number of cached prepared statements getter

Returns
the maximum number of cached prepared statements
Since
0.2
Here is the call graph for this function:

◆ guard()

template<typename F>
auto anch::sql::Connection::guard ( F && func) -> decltype(func())
protected

Call function and report its SqlException to the connection (see onError )

Template Parameters
Fthe function type
Parameters
functhe function to call
Returns
the function result
Exceptions
SqlExceptionthe function error (rethrown)
Since
0.2
Here is the call graph for this function:

◆ isValid()

bool anch::sql::Connection::isValid ( ) const
noexcept

Valid status getter: false once a fatal error has occurred, or when the driver reports a broken connection. Connection pools destroy invalid connections instead of reusing them.

Returns
the status
Here is the call graph for this function:

◆ makePrepared()

virtual PreparedStatement * anch::sql::Connection::makePrepared ( const std::string & query)
protectedpure virtual

Send SQL query to prepare SQL statement

Parameters
querythe SQL query
Returns
the prepared statement
Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLConnection, anch::sql::PostgreSQLConnection, and anch::sql::SQLite3Connection.

Here is the call graph for this function:

◆ onError()

void anch::sql::Connection::onError ( const SqlException & error)
protectednoexcept

Report error: a fatal error invalidates the connection

Parameters
errorthe error
Since
0.2
Here is the call graph for this function:

◆ prepareStatement()

PreparedStatement & anch::sql::Connection::prepareStatement ( const std::string & query)

Prepare SQL statement if not already done.
The statement is cached by the connection (see setStatementCacheSize ): the returned reference remains valid until the statement is evicted, that is to say at least until statementCacheSize - 1 other queries have been prepared on this connection (and as long as one of its result sets is alive).

Parameters
querythe SQL query
Returns
the prepared statement
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ query() [1/3]

ResultSet * anch::sql::Connection::query ( const std::string & query)

Execute SQL query

Parameters
querythe SQL query to execute
Returns
the result set which has to be deleted after use
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ query() [2/3]

template<anch::Described T>
ResultSet * anch::sql::Connection::query ( const std::string & query,
const anch::sql::FieldsOf< T > & fields )

Execute SQL prepared statement query with the fields of an object as parameters ( fieldsOf )

Parameters
querythe SQL query to execute (with named parameters: :name )
fieldsthe fields of the object
Returns
the result set which has to be deleted after use
Exceptions
SqlExceptionany error (a parameter which is not a field is not bound: non fatal)
Since
0.3
Here is the call graph for this function:

◆ query() [3/3]

ResultSet * anch::sql::Connection::query ( const std::string & query,
const anch::sql::Parameters & parameters )

Execute SQL prepared statement query

Parameters
querythe SQL query to execute (with named parameters: :name )
parametersthe parameters (every parameter of the query has to be given)
Returns
the result set which has to be deleted after use
Exceptions
SqlExceptionany error (missing or unknown parameter: non fatal)
Here is the call graph for this function:

◆ queryEach() [1/3]

template<anch::sql::Row T>
void anch::sql::Connection::queryEach ( const std::string & query,
std::function< void(T &&)> rowHandler )

Execute query and treat each row of its result, read one at a time ( RowReader )

Template Parameters
Tthe row type
Parameters
querythe SQL query to execute
rowHandlerthe row handler function
Exceptions
SqlExceptionany error (invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryEach() [2/3]

void anch::sql::Connection::queryEach ( const std::string & query,
std::function< void(T &&)> rowHandler,
const anch::sql::FieldsOf< U > & fields )

Execute query and treat each row of its result, read one at a time ( RowReader )

Template Parameters
Tthe row type
Uthe type of the object whose fields are parameters
Parameters
querythe SQL query to execute (with named parameters: :name )
rowHandlerthe row handler function
fieldsthe fields of an object as parameters ( fieldsOf )
Exceptions
SqlExceptionany error (invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryEach() [3/3]

template<anch::sql::Row T>
void anch::sql::Connection::queryEach ( const std::string & query,
std::function< void(T &&)> rowHandler,
const anch::sql::Parameters & parameters )

Execute query and treat each row of its result, read one at a time ( RowReader )

Template Parameters
Tthe row type
Parameters
querythe SQL query to execute (with named parameters: :name )
rowHandlerthe row handler function
parametersthe parameters
Exceptions
SqlExceptionany error (invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryExtract() [1/3]

template<anch::Described T>
void anch::sql::Connection::queryExtract ( const std::string & query,
std::function< void(ResultSet &)> resExtractor,
const anch::sql::FieldsOf< T > & fields )

Execute query with the fields of an object as parameters and extract result set

Parameters
querythe SQL query to execute (with named parameters: :name )
resExtractorthe result set extractor function
fieldsthe fields of the object ( fieldsOf )
Exceptions
SqlExceptionany error
Since
0.3
Here is the call graph for this function:

◆ queryExtract() [2/3]

void anch::sql::Connection::queryExtract ( const std::string & query,
std::function< void(ResultSet &)> resExtractor,
const anch::sql::Parameters & parameters )

Execute query and extract result set

Parameters
querythe SQL query to execute (with named parameters: :name )
resExtractorthe result set extractor function
parametersthe parameters (every parameter of the query has to be given)
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ queryExtract() [3/3]

void anch::sql::Connection::queryExtract ( const std::string & sqlQuery,
std::function< void(ResultSet &)> resExtractor )

Execute query and extract result set

Parameters
sqlQuerythe SQL query to execute
resExtractorthe result set extractor function
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ queryList() [1/3]

template<anch::sql::Row T>
std::vector< T > anch::sql::Connection::queryList ( const std::string & query)

Execute query and read all the rows of its result ( RowReader : columns are associated with the fields of a described type by name, a value is read from the first column):

const std::string select = "SELECT id,first_name,last_name,birth_date,COALESCE(email, '') AS email FROM T_Test";
std::vector<Person> all = dbCon.queryList<Person>(select);
std::optional<Person> george = dbCon.queryOne<Person>(select + " WHERE id = :id", {{"id", 2}});
dbCon.queryEach<Person>(select, [](Person&& person) { std::cout << "Read " << person._firstName << std::endl; });
std::vector<int64_t> ids = dbCon.queryList<int64_t>("SELECT id FROM T_Test ORDER BY id");
Template Parameters
Tthe row type
Parameters
querythe SQL query to execute
Returns
the rows
Exceptions
SqlExceptionany error (invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryList() [2/3]

std::vector< T > anch::sql::Connection::queryList ( const std::string & query,
const anch::sql::FieldsOf< U > & fields )

Execute query and read all the rows of its result ( RowReader : columns are associated with the fields of a described type by name, a value is read from the first column):

const std::string select = "SELECT id,first_name,last_name,birth_date,COALESCE(email, '') AS email FROM T_Test";
std::vector<Person> all = dbCon.queryList<Person>(select);
std::optional<Person> george = dbCon.queryOne<Person>(select + " WHERE id = :id", {{"id", 2}});
dbCon.queryEach<Person>(select, [](Person&& person) { std::cout << "Read " << person._firstName << std::endl; });
std::vector<int64_t> ids = dbCon.queryList<int64_t>("SELECT id FROM T_Test ORDER BY id");
Template Parameters
Tthe row type
Uthe type of the object whose fields are parameters
Parameters
querythe SQL query to execute (with named parameters: :name )
fieldsthe fields of an object as parameters ( fieldsOf )
Returns
the rows
Exceptions
SqlExceptionany error (invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryList() [3/3]

template<anch::sql::Row T>
std::vector< T > anch::sql::Connection::queryList ( const std::string & query,
const anch::sql::Parameters & parameters )

Execute query and read all the rows of its result ( RowReader : columns are associated with the fields of a described type by name, a value is read from the first column):

const std::string select = "SELECT id,first_name,last_name,birth_date,COALESCE(email, '') AS email FROM T_Test";
std::vector<Person> all = dbCon.queryList<Person>(select);
std::optional<Person> george = dbCon.queryOne<Person>(select + " WHERE id = :id", {{"id", 2}});
dbCon.queryEach<Person>(select, [](Person&& person) { std::cout << "Read " << person._firstName << std::endl; });
std::vector<int64_t> ids = dbCon.queryList<int64_t>("SELECT id FROM T_Test ORDER BY id");
Template Parameters
Tthe row type
Parameters
querythe SQL query to execute (with named parameters: :name )
parametersthe parameters
Returns
the rows
Exceptions
SqlExceptionany error (invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryMapRow() [1/3]

template<anch::Described T>
void anch::sql::Connection::queryMapRow ( const std::string & query,
std::function< void(ResultSet &)> rowMapper,
const anch::sql::FieldsOf< T > & fields )

Execute query with the fields of an object as parameters and treat each row of result set

Parameters
querythe SQL query to execute (with named parameters: :name )
rowMapperthe row mapper function
fieldsthe fields of the object ( fieldsOf )
Exceptions
SqlExceptionany error
Since
0.3
Here is the call graph for this function:

◆ queryMapRow() [2/3]

void anch::sql::Connection::queryMapRow ( const std::string & query,
std::function< void(ResultSet &)> rowMapper,
const anch::sql::Parameters & parameters )

Execute query and treat each row of result set

Parameters
querythe SQL query to execute (with named parameters: :name )
rowMapperthe row mapper function
parametersthe parameters (every parameter of the query has to be given)
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ queryMapRow() [3/3]

void anch::sql::Connection::queryMapRow ( const std::string & sqlQuery,
std::function< void(ResultSet &)> rowMapper )

Execute query and treat each row of result set

Parameters
sqlQuerythe SQL query to execute
rowMapperthe row mapper function
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ queryOne() [1/3]

template<anch::sql::Row T>
std::optional< T > anch::sql::Connection::queryOne ( const std::string & query)

Execute query and read its only row ( RowReader )

Template Parameters
Tthe row type
Parameters
querythe SQL query to execute
Returns
the row, std::nullopt when there is no row
Exceptions
SqlExceptionany error (more than one row, invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryOne() [2/3]

std::optional< T > anch::sql::Connection::queryOne ( const std::string & query,
const anch::sql::FieldsOf< U > & fields )

Execute query and read its only row ( RowReader )

Template Parameters
Tthe row type
Uthe type of the object whose fields are parameters
Parameters
querythe SQL query to execute (with named parameters: :name )
fieldsthe fields of an object as parameters ( fieldsOf )
Returns
the row, std::nullopt when there is no row
Exceptions
SqlExceptionany error (more than one row, invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ queryOne() [3/3]

template<anch::sql::Row T>
std::optional< T > anch::sql::Connection::queryOne ( const std::string & query,
const anch::sql::Parameters & parameters )

Execute query and read its only row ( RowReader )

Template Parameters
Tthe row type
Parameters
querythe SQL query to execute (with named parameters: :name )
parametersthe parameters
Returns
the row, std::nullopt when there is no row
Exceptions
SqlExceptionany error (more than one row, invalid value, NULL value which is not optional: non fatal)
Since
0.3
Here is the call graph for this function:

◆ release()

void anch::sql::Connection::release ( )
noexcept

Release connection: roll back the current transaction, if any (a transaction is committed only by commit ).
It is called when the connection is returned to its pool and when it is destroyed. If the transaction can be neither committed nor rolled back, the connection is invalidated (its transaction state is unknown).

Here is the call graph for this function:

◆ rollback()

void anch::sql::Connection::rollback ( )

Rollback current SQL transaction.
If there is not transaction, this method does nothing.

Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ sendCommit()

virtual void anch::sql::Connection::sendCommit ( )
protectedpure virtual

Send commit to database server

Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLConnection, anch::sql::PostgreSQLConnection, and anch::sql::SQLite3Connection.

Here is the call graph for this function:

◆ sendRollback()

virtual void anch::sql::Connection::sendRollback ( )
protectedpure virtual

Send rollback to database server

Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLConnection, anch::sql::PostgreSQLConnection, and anch::sql::SQLite3Connection.

Here is the call graph for this function:

◆ sendStartTransaction()

virtual void anch::sql::Connection::sendStartTransaction ( )
protectedpure virtual

Send start transaction to database server

Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLConnection, anch::sql::PostgreSQLConnection, and anch::sql::SQLite3Connection.

Here is the call graph for this function:

◆ setStatementCacheSize()

void anch::sql::Connection::setStatementCacheSize ( std::size_t size)

Maximum number of cached prepared statements setter: least recently used statements are evicted when the cache exceeds the new size

Parameters
sizethe maximum number of cached prepared statements (at least 1 )
Exceptions
SqlExceptioninvalid size
Since
0.2
Here is the call graph for this function:

◆ setValid()

void anch::sql::Connection::setValid ( bool valid)
protectednoexcept

Valid status setter

Parameters
validthe status to set
Here is the call graph for this function:

◆ startTransaction()

void anch::sql::Connection::startTransaction ( )

Start SQL transaction.
If there is a transaction on this database connection, this method does nothing.
The transaction has to be ended with commit or rollback : it is rolled back by release otherwise.

Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ update() [1/3]

uint64_t anch::sql::Connection::update ( const std::string & query)

Execute update (INSERT, UPDATE or DELETE) SQL query.

Parameters
querythe SQL query
Returns
the number of affected rows
Exceptions
SqlExceptionany error
Here is the call graph for this function:

◆ update() [2/3]

template<anch::Described T>
uint64_t anch::sql::Connection::update ( const std::string & query,
const anch::sql::FieldsOf< T > & fields )

Execute update (INSERT, UPDATE or DELETE) SQL prepared statement with the fields of an object as parameters

Parameters
querythe SQL query (with named parameters: :name )
fieldsthe fields of the object ( fieldsOf )
Returns
the number of affected rows
Exceptions
SqlExceptionany error
Since
0.3
Here is the call graph for this function:

◆ update() [3/3]

uint64_t anch::sql::Connection::update ( const std::string & query,
const anch::sql::Parameters & parameters )

Execute update (INSERT, UPDATE or DELETE) SQL prepared statement.

Parameters
querythe SQL query (with named parameters: :name )
parametersthe parameters (every parameter of the query has to be given)
Returns
the number of affected rows
Exceptions
SqlExceptionany error
Here is the call graph for this function:

Member Data Documentation

◆ _stmts

std::list<CachedStatement> anch::sql::Connection::_stmts
protected

Prepared statements (the most recently used first)

◆ _stmtsIndex

std::unordered_map<std::string_view, std::list<CachedStatement>::iterator> anch::sql::Connection::_stmtsIndex
protected

Prepared statements index (keys are views of CachedStatement::query )

◆ _stmtsMax

std::size_t anch::sql::Connection::_stmtsMax
protected

Maximum number of cached prepared statements

◆ _transaction

bool anch::sql::Connection::_transaction
protected

Is in SQL transaction

◆ _valid

bool anch::sql::Connection::_valid
protected

Is SQL connection valid


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