5#include "../../Api.hpp"
6#include "../../SqlBindingTypes.hpp"
7#include "../../SqlConnectInfo.hpp"
8#include "../../SqlError.hpp"
9#include "../Concept.hpp"
13#include <source_location>
24namespace Lightweight::Driver::Sqlite3
44[[nodiscard]] LIGHTWEIGHT_API std::expected<void, SqlErrorInfo>
Close(
Connection& connection,
45 CloseDiagnostic diagnostic)
noexcept;
59 return connection.state !=
nullptr;
167 [[maybe_unused]] std::source_location location)
noexcept
169 return ::Lightweight::Driver::CallOutcome { .
succeeded = Succeeded(result), .injectedError = std::nullopt };
177[[nodiscard]] LIGHTWEIGHT_API std::expected<std::string, SqlErrorInfo> SearchPatternEscape(
Connection const& connection);
201 std::source_location location);
205static_assert(::Lightweight::Driver::SqlDriverConnectionOperations<Driver>);
bool IsAllocated(ConnectionHandle const &connection) noexcept
Tells whether connection holds a driver connection (connected or not).
std::string ServerVersion(ConnectionHandle const &connection)
The version of the DBMS the connection is connected to.
std::expected< void, SqlErrorInfo > Connect(ConnectionHandle &handle, Info const &info, std::source_location location)
Connects handle from info through the enabled driver that connects from it.
bool TransactionActive(ConnectionHandle const &connection) noexcept
Tells whether a transaction is open, i.e. autocommit is off.
void Allocate(ConnectionHandle &connection) noexcept
Allocates the driver's connection resources, unless the connection already holds them.
SqlResult SetAutoCommit(ConnectionHandle &connection, bool enabled) noexcept
Switches autocommit mode on or off.
std::string ServerName(ConnectionHandle const &connection)
The name of the DBMS the connection is connected to.
SqlResult SetIsolation(ConnectionHandle &connection, SqlIsolationMode mode) noexcept
Sets the transaction isolation level of the connection.
bool RollbackOpenTransaction(ConnectionHandle &connection) noexcept
Rolls back the open transaction and switches autocommit back on.
SqlErrorInfo LastError(ConnectionHandle const &connection)
Reads the connection's diagnostics: the first record its last failed call left.
SqlResult Disconnect(ConnectionHandle &connection) noexcept
Ends the connection's session, keeping its driver resources for the next connect.
SqlResult Commit(ConnectionHandle &connection) noexcept
Commits the open transaction.
std::string DriverName(ConnectionHandle const &connection)
The name of the driver (library) the connection runs on.
std::string UserName(ConnectionHandle const &connection)
The name of the user the connection is logged in as.
std::expected< void, SqlErrorInfo > Close(ConnectionHandle &connection, CloseDiagnostic diagnostic) noexcept
Closes the connection: disconnects it, frees its driver resources and leaves connection empty,...
SqlResult Rollback(ConnectionHandle &connection) noexcept
Rolls back the open transaction.
bool TransactionsAllowed(ConnectionHandle const &connection) noexcept
Tells whether the data source supports transactions.
std::string DatabaseName(ConnectionHandle const &connection)
The name of the database in use.
CallOutcome CheckResult(StatementHandle const &statement, SqlResult result, std::source_location location)
The non-throwing, fault-seam-aware verdict on result.
bool IsAlive(ConnectionHandle const &connection) noexcept
Tells whether the driver still considers the connection alive.
bool succeeded
Whether the checked call should be treated as having succeeded.
The SQLite3 driver's connection handle struct: one pointer to the driver-owned connection state.
Represents a SQL error as reported by the database driver.
What a connection to a SQLite database is opened from through the native SQLite3 driver.