AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | List of all members
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 &host, const std::string &user, const std::string &password, const std::string &database, int port, const std::string &app="") throw (SqlException)
 
 PostgreSQLConnection (const std::string &connStr) throw (SqlException)
 
 PostgreSQLConnection (const SqlConnectionConfiguration &config) throw (SqlException)
 
 PostgreSQLConnection (const PostgreSQLConnection &)=delete
 
 ~PostgreSQLConnection ()
 
- Public Member Functions inherited from anch::sql::Connection
 Connection () throw (SqlException)
 
 Connection (const Connection &)=delete
 
virtual ~Connection ()
 
void commit () throw (SqlException)
 
void rollback () throw (SqlException)
 
void setAutoCommit (bool autoCommit) throw (SqlException)
 
ResultSetquery (const std::string &query) throw (SqlException)
 
void queryMapRow (const std::string &sqlQuery, std::function< void(ResultSet &)> rowMapper) throw (SqlException)
 
void queryExtract (const std::string &sqlQuery, std::function< void(ResultSet &)> resExtractor) throw (SqlException)
 
uint64_t update (const std::string &query) throw (SqlException)
 
bool isAutoCommit () const
 
bool isValid () const
 

Protected Member Functions

virtual ResultSetexecuteQuery (const std::string &query) override throw (SqlException)
 
virtual uint64_t executeUpdate (const std::string &query) override throw (SqlException)
 
virtual void sendCommit () override throw (SqlException)
 
virtual void sendRollback () override throw (SqlException)
 
virtual void toggleAutoCommit (bool autoCommit) override throw (SqlException)
 
- Protected Member Functions inherited from anch::sql::Connection
void setValid (bool valid)
 

Additional Inherited Members

- Protected Attributes inherited from anch::sql::Connection
bool _autoCommit
 
bool _valid
 

Detailed Description

PostgreSQL connection.

SQL connection implementation through PostgreSQL native library

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

PostgreSQLConnection::PostgreSQLConnection ( const std::string &  host,
const std::string &  user,
const std::string &  password,
const std::string &  database,
int  port,
const std::string &  app = "" 
)
throw (SqlException
)

PostgreSQLConnection constructor

Parameters
hostthe PostgreSQL server hostname
userthe datase user login
passwordthe database login password
databasethe database name
portthe database access port
appthe application name
Exceptions
SqlExceptionfail to create connection
PostgreSQLConnection::PostgreSQLConnection ( const std::string &  connStr)
throw (SqlException
)

PostgreSQLConnection constructor

Parameters
connStrthe PostgreSQL connection string
Exceptions
SqlExceptionfail to create connection
PostgreSQLConnection::PostgreSQLConnection ( const SqlConnectionConfiguration config)
throw (SqlException
)

PostgreSQLConnection constructor

Parameters
configthe PostgreSQL database configuration
Exceptions
SqlExceptionfail to create connection
anch::sql::PostgreSQLConnection::PostgreSQLConnection ( const PostgreSQLConnection )
delete

Prohibit PostgreSQLConnection copy constructor

PostgreSQLConnection::~PostgreSQLConnection ( )
noexcept

Member Function Documentation

ResultSet * PostgreSQLConnection::executeQuery ( const std::string &  query)
throw (SqlException
)
overrideprotectedvirtual

Execute SQL select query

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

Implements anch::sql::Connection.

uint64_t PostgreSQLConnection::executeUpdate ( const std::string &  query)
throw (SqlException
)
overrideprotectedvirtual

Execute SQL update query

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

Implements anch::sql::Connection.

void PostgreSQLConnection::sendCommit ( )
throw (SqlException
)
overrideprotectedvirtual

Send commit to database server

Exceptions
SqlExceptionfail to commit transaction

Implements anch::sql::Connection.

void PostgreSQLConnection::sendRollback ( )
throw (SqlException
)
overrideprotectedvirtual

Send rollback to database server

Exceptions
SqlExceptionfail to rollback transaction

Implements anch::sql::Connection.

void PostgreSQLConnection::toggleAutoCommit ( bool  autoCommit)
throw (SqlException
)
overrideprotectedvirtual

Send auto commit status modification to server

Parameters
autoCommitthe status to send
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.


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