AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
anch::sql::PostgreSQLConnection Class Reference

PostgreSQL connection. More...

#include <postgresqlConnection.hpp>

Inheritance diagram for anch::sql::PostgreSQLConnection:
Collaboration diagram for anch::sql::PostgreSQLConnection:

Public Member Functions

 PostgreSQLConnection (const std::string &connStr)
 PostgreSQLConnection (const SqlConnectionConfiguration &config)
 PostgreSQLConnection (const PostgreSQLConnection &)=delete
virtual ~PostgreSQLConnection () noexcept
Public Member Functions inherited from anch::sql::Connection
 Connection ()
 Connection (const Connection &)=delete
virtual ~Connection () noexcept
void startTransaction ()
void begin ()
void commit ()
void rollback ()
void release () noexcept
PreparedStatementprepareStatement (const std::string &query)
ResultSetquery (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)
template<typename T, typename... Q>
ResultSetquery (const std::string &query, const T &value, const Q &... values)
template<typename T, typename... Q>
void queryMapRow (const std::string &query, std::function< void(ResultSet &)> rowMapper, const T &value, const Q &... values)
template<typename T, typename... Q>
void queryExtract (const std::string &query, std::function< void(ResultSet &)> resExtractor, const T &value, const Q &... values)
uint64_t update (const std::string &query)
template<typename T, typename... Q>
uint64_t update (const std::string &query, const T &value, const Q &... values)
template<typename T, typename Iterable>
uint64_t batchUpdate (const std::string &query, std::function< void(PreparedStatement &, const T &)> mapper, const Iterable &values)
bool isValid () const noexcept

Protected Member Functions

virtual ResultSetexecuteQuery (const std::string &query) override
virtual uint64_t executeUpdate (const std::string &query) override
virtual void sendCommit () override
virtual void sendRollback () override
virtual void sendStartTransaction () override
virtual PreparedStatementmakePrepared (const std::string &query) override
Protected Member Functions inherited from anch::sql::Connection
void setValid (bool valid) noexcept

Additional Inherited Members

Protected Attributes inherited from anch::sql::Connection
bool _valid
bool _transaction
std::map< std::string, PreparedStatement * > _stmts
bool _errors

Detailed Description

PostgreSQL connection.

SQL connection implementation through PostgreSQL native library

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ PostgreSQLConnection() [1/3]

anch::sql::PostgreSQLConnection::PostgreSQLConnection ( const std::string & connStr)

PostgreSQLConnection constructor

Parameters
connStrthe PostgreSQL connection string
Exceptions
SqlExceptionfail to create connection

◆ PostgreSQLConnection() [2/3]

anch::sql::PostgreSQLConnection::PostgreSQLConnection ( const SqlConnectionConfiguration & config)

PostgreSQLConnection constructor

Parameters
configthe PostgreSQL database configuration
Exceptions
SqlExceptionfail to create connection

◆ PostgreSQLConnection() [3/3]

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

Prohibit PostgreSQLConnection copy constructor

Here is the call graph for this function:

◆ ~PostgreSQLConnection()

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

Member Function Documentation

◆ executeQuery()

virtual ResultSet * anch::sql::PostgreSQLConnection::executeQuery ( const std::string & query)
overrideprotectedvirtual

Execute SQL select query

Parameters
querythe SQL query to execute
Returns
the result set
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

Here is the call graph for this function:

◆ executeUpdate()

virtual uint64_t anch::sql::PostgreSQLConnection::executeUpdate ( const std::string & query)
overrideprotectedvirtual

Execute SQL update query

Parameters
querythe SQL query to execute
Returns
the number of updated rows
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

Here is the call graph for this function:

◆ makePrepared()

virtual PreparedStatement * anch::sql::PostgreSQLConnection::makePrepared ( const std::string & query)
overrideprotectedvirtual

Send SQL query to prepare SQL statement

Parameters
querythe SQL query
Returns
the prepared statement
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

Here is the call graph for this function:

◆ sendCommit()

virtual void anch::sql::PostgreSQLConnection::sendCommit ( )
overrideprotectedvirtual

Send commit to database server

Exceptions
SqlExceptionfail to commit transaction

Implements anch::sql::Connection.

Here is the call graph for this function:

◆ sendRollback()

virtual void anch::sql::PostgreSQLConnection::sendRollback ( )
overrideprotectedvirtual

Send rollback to database server

Exceptions
SqlExceptionfail to rollback transaction

Implements anch::sql::Connection.

Here is the call graph for this function:

◆ sendStartTransaction()

virtual void anch::sql::PostgreSQLConnection::sendStartTransaction ( )
overrideprotectedvirtual

Send start transaction to database server

Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

Here is the call graph for this function:

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