1 #ifndef ZSERIO_SQL_CONNECTION_H_INC 2 #define ZSERIO_SQL_CONNECTION_H_INC 125 sqlite3* m_connection;
130 : m_connection(connection), m_connectionType(connectionType)
142 sqlite3_close_v2(m_connection);
144 m_connection = connection;
145 m_connectionType = connectionType;
150 return m_connectionType;
160 std::unique_ptr<sqlite3_stmt, SqliteFinalizer> statement(
prepareStatement(sqlQuery));
161 int result = sqlite3_step(statement.get());
162 if (result != SQLITE_DONE)
164 throw SqliteException(
"SqliteConnection::executeUpdate(): sqlite3_step failed: ") <<
171 sqlite3_stmt* statement =
nullptr;
172 const int result = sqlite3_prepare_v2(m_connection, sqlQuery.
data(),
static_cast<int>(sqlQuery.
size()),
173 &statement,
nullptr);
174 if (result != SQLITE_OK)
176 throw SqliteException(
"SqliteConnection::prepareStatement(): sqlite3_prepare_v2() failed: ") <<
185 bool wasTransactionStarted =
false;
186 if (sqlite3_get_autocommit(m_connection) != 0)
189 wasTransactionStarted =
true;
192 return wasTransactionStarted;
197 if (wasTransactionStarted)
203 #endif // ZSERIO_SQL_CONNECTION_H_INC constexpr size_type size() const noexcept
SqliteConnection & operator=(const SqliteConnection &)=delete
constexpr const_pointer data() const noexcept
ConnectionType getConnectionType() const
sqlite3_stmt * prepareStatement(StringView sqlQuery)
void reset(sqlite3 *connection=nullptr, ConnectionType connectionType=INTERNAL_CONNECTION)
sqlite3 * getConnection()
SqliteConnection(sqlite3 *connection=nullptr, ConnectionType connectionType=INTERNAL_CONNECTION)
void executeUpdate(StringView sqlQuery)
void endTransaction(bool wasTransactionStarted)