1 // Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef SQL_CONNECTION_H_
6 #define SQL_CONNECTION_H_
13 #include "src/sql_transaction.h"
22 SQLConnection() : error_code_(0), transaction_(this) {}
23 virtual ~SQLConnection() = default;
25 virtual bool Execute(const std::string& command) = 0;
27 virtual std::shared_ptr<SQLStatement> PrepareStatement(
28 const std::string& query) = 0;
30 virtual bool IsValid() = 0;
32 virtual void SetErrorCode(int error_code) {
33 error_code_ = error_code;
36 virtual int GetErrorCode() {
40 virtual std::unique_lock<const SQLTransaction> GetTransactionGuard() {
41 return std::move(std::unique_lock<const SQLTransaction>(transaction_));
45 friend class SQLTransaction;
47 virtual void UnsetErrorCode() {
51 virtual bool BeginTransaction() = 0;
52 virtual bool CommitTransaction() = 0;
53 virtual bool RollbackTransaction() = 0;
56 SQLTransaction transaction_;
61 #endif // SQL_CONNECTION_H_