AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
postgresqlConnection.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 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 <https://www.gnu.org/licenses/>.
19*/
20#ifdef ANCH_SQL_POSTGRESQL
21#pragma once
22
23#include "anch-postgresql-export.hpp"
24
25#include "sql/connection.hpp"
26
27
28typedef struct pg_conn PGconn;
29typedef struct pg_result PGresult;
30
31
32namespace anch::sql::postgresql {
33
43 ANCH_POSTGRESQL_EXPORT uint64_t affectedRows(PGresult* res) noexcept;
44
56 ANCH_POSTGRESQL_EXPORT SqlException error(const std::string& message, PGconn* conn, PGresult* res = NULL);
57
69 ANCH_POSTGRESQL_EXPORT bool invalidatesStatement(const PGresult* res) noexcept;
70
71} // anch::sql::postgresql
72
73namespace anch::sql {
74
84 class ANCH_POSTGRESQL_EXPORT PostgreSQLConnection: public Connection {
85
86 // Attributes +
87 private:
89 PGconn* _conn;
90 // Attributes -
91
92 // Constructors +
93 public:
101 PostgreSQLConnection(const std::string& connStr);
102
111
116 // Constructors -
117
118 // Destructor +
122 virtual ~PostgreSQLConnection() noexcept;
123 // Destructor -
124
125 // Methods +
126 protected:
136 virtual ResultSet* executeQuery(const std::string& query) override;
137
147 virtual uint64_t executeUpdate(const std::string& query) override;
148
154 virtual bool checkConnection() const noexcept override;
155
161 virtual void sendCommit() override;
162
168 virtual void sendRollback() override;
169
175 virtual void sendStartTransaction() override;
176
186 virtual PreparedStatement* makePrepared(const std::string& query) override;
187 // Methods -
188
189 };
190
191} // anch::sql
192
193#endif // ANCH_SQL_POSTGRESQL
ResultSet * query(const std::string &query)
Connection(std::size_t statementCacheSize=DEFAULT_STATEMENT_CACHE_SIZE)
virtual ~PostgreSQLConnection() noexcept
virtual ResultSet * executeQuery(const std::string &query) override
virtual PreparedStatement * makePrepared(const std::string &query) override
PostgreSQLConnection(const std::string &connStr)
PostgreSQLConnection(const SqlConnectionConfiguration &config)
virtual uint64_t executeUpdate(const std::string &query) override
virtual void sendStartTransaction() override
PostgreSQLConnection(const PostgreSQLConnection &)=delete
virtual void sendRollback() override
virtual bool checkConnection() const noexcept override
virtual void sendCommit() override
SQL namespace.
Definition clauses.hpp:28
SQL database connection configuration.
Definition connection.hpp:55