AnCH Framework  0.1
Another C++ Hack Framework
postgresqlConnection.hpp
1 /*
2  ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3  Copyright (C) 2012 Vincent Lachenal
4 
5  This file is part of ANCH Framework.
6 
7  ANCH Framework is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  ANCH Framework is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifdef ANCH_SQL_POSTGRESQL
21 #ifndef _ANCH_SQL_PGCON_H_
22 #define _ANCH_SQL_PGCON_H_
23 
24 #include "sql/connection.hpp"
25 
26 #include "libpq-fe.h"
27 
28 
29 namespace anch {
30  namespace sql {
31 
42 
43  // Attributes +
44  private:
46  PGconn* _conn;
47  // Attributes -
48 
49  // Constructors +
50  public:
63  PostgreSQLConnection(const std::string& host,
64  const std::string& user,
65  const std::string& password,
66  const std::string& database,
67  int port,
68  const std::string& app = "")
69  throw(SqlException);
70 
78  PostgreSQLConnection(const std::string& connStr) throw(SqlException);
79 
88 
93  // Constructors -
94 
95  // Destructor +
100  // Destructor -
101 
102  // Methods +
103  protected:
113  virtual ResultSet* executeQuery(const std::string& query) throw(SqlException) override;
114 
124  virtual uint64_t executeUpdate(const std::string& query) throw(SqlException) override;
125 
131  virtual void sendCommit() throw(SqlException) override;
132 
138  virtual void sendRollback() throw(SqlException) override;
139 
147  virtual void toggleAutoCommit(bool autoCommit) throw(SqlException) override;
148  // Methods -
149 
150  };
151 
152  }
153 }
154 
155 #endif // _ANCH_SQL_PGCON_H_
156 #endif // ANCH_SQL_POSTGRESQL
SQL database connection configuration.
Definition: connection.hpp:41
virtual ResultSet * executeQuery(const std::string &query) override
Definition: postgresqlConnection.cpp:174
PostgreSQL connection.
Definition: postgresqlConnection.hpp:41
virtual uint64_t executeUpdate(const std::string &query) override
Definition: postgresqlConnection.cpp:186
SQL exception.
Definition: sqlException.hpp:39
virtual void toggleAutoCommit(bool autoCommit) override
Definition: postgresqlConnection.cpp:169
~PostgreSQLConnection()
Definition: postgresqlConnection.cpp:134
SQL result representation.
Definition: resultSet.hpp:44
AnCH framework base namespace.
Definition: base64.hpp:28
SQL connection virtual class.
Definition: connection.hpp:73
virtual void sendRollback() override
Definition: postgresqlConnection.cpp:156
PostgreSQLConnection(const std::string &host, const std::string &user, const std::string &password, const std::string &database, int port, const std::string &app="")
Definition: postgresqlConnection.cpp:37
ResultSet * query(const std::string &query)
Definition: connection.cpp:61
virtual void sendCommit() override
Definition: postgresqlConnection.cpp:143