50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#ifndef QUERY_CONNECTION_HPP
|
|
#define QUERY_CONNECTION_HPP
|
|
|
|
#include "matador/sql/connection_info.hpp"
|
|
#include "matador/sql/connection_impl.hpp"
|
|
#include "matador/sql/dialect.hpp"
|
|
#include "matador/sql/query_context.hpp"
|
|
#include "matador/sql/query_result.hpp"
|
|
#include "matador/sql/record.hpp"
|
|
#include "matador/sql/statement.hpp"
|
|
|
|
#include "matador/utils/logger.hpp"
|
|
|
|
#include <string>
|
|
|
|
namespace matador::sql {
|
|
|
|
class connection
|
|
{
|
|
public:
|
|
explicit connection(connection_info info);
|
|
explicit connection(const std::string& dns);
|
|
connection(const connection &x);
|
|
connection& operator=(const connection &x);
|
|
connection(connection &&x) noexcept = default;
|
|
connection& operator=(connection &&x) noexcept = default;
|
|
~connection();
|
|
|
|
void open();
|
|
void close();
|
|
[[nodiscard]] bool is_open() const;
|
|
[[nodiscard]] const connection_info& info() const;
|
|
|
|
[[nodiscard]] record describe(const std::string &table_name) const;
|
|
[[nodiscard]] bool exists(const std::string &table_name) const;
|
|
|
|
[[nodiscard]] std::unique_ptr<query_result_impl> fetch(const std::string &sql) const;
|
|
[[nodiscard]] size_t execute(const std::string &sql) const;
|
|
|
|
statement prepare(query_context &&query) const;
|
|
|
|
private:
|
|
connection_info connection_info_;
|
|
std::unique_ptr<connection_impl> connection_;
|
|
utils::logger logger_;
|
|
};
|
|
|
|
}
|
|
#endif //QUERY_CONNECTION_HPP
|