RhythmGame 1.4.3
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
db::SqliteCppDb Class Reference

Database wrapper for SQLiteCpp. More...

#include <SqliteCppDb.h>

Classes

class  Statement
 Wrapper for SQLiteCpp::Statement. More...
 
class  Transaction
 Isolates a transaction from other users of this connection. More...
 

Public Types

enum class  Durability { Normal , Full }
 

Public Member Functions

auto transaction () -> Transaction
 
 SqliteCppDb (const std::filesystem::path &dbPath, std::chrono::milliseconds busyTimeout=std::chrono::milliseconds{ 0 }, Durability durability=Durability::Normal)
 Constructs a database wrapper.
 
void execute (const std::string &query)
 Executes a query.
 
auto createStatement (const std::string &query) -> Statement
 
auto hasTable (const std::string &table) const -> bool
 Queries the database to inspect whether the table with the provided name exists.
 

Static Public Member Functions

static auto openReadOnly (const std::filesystem::path &dbPath, std::chrono::milliseconds busyTimeout=std::chrono::milliseconds{ 0 }) -> SqliteCppDb
 

Detailed Description

Database wrapper for SQLiteCpp.

Note
Independent statements may share a connection across threads. Use a transaction to isolate a sequence of operations on that connection.

Member Enumeration Documentation

◆ Durability

enum class db::SqliteCppDb::Durability
strong
Enumerator
Normal 
Full 

Constructor & Destructor Documentation

◆ SqliteCppDb()

db::SqliteCppDb::SqliteCppDb ( const std::filesystem::path &  dbPath,
std::chrono::milliseconds  busyTimeout = std::chrono::milliseconds{ 0 },
Durability  durability = Durability::Normal 
)
explicit

Constructs a database wrapper.

Parameters
dbPathPath to the database file. The database file will be created if it does not exist.
busyTimeoutHow long to wait for locks held by other connections. Shared-connection transactions are serialized independently of this timeout.
durabilityFull synchronizes each WAL commit for persistent user data.

Member Function Documentation

◆ createStatement()

auto db::SqliteCppDb::createStatement ( const std::string &  query) -> Statement

◆ execute()

void db::SqliteCppDb::execute ( const std::string &  query)

Executes a query.

Note
Good for single-use queries. Use Statement otherwise.
Parameters
queryQuery to execute.

◆ hasTable()

auto db::SqliteCppDb::hasTable ( const std::string &  table) const -> bool

Queries the database to inspect whether the table with the provided name exists.

Parameters
tableName of the table.
Returns
True if the table exists, false otherwise.

◆ openReadOnly()

auto db::SqliteCppDb::openReadOnly ( const std::filesystem::path &  dbPath,
std::chrono::milliseconds  busyTimeout = std::chrono::milliseconds{ 0 } 
) -> SqliteCppDb
static

Opens an existing database for reads, without write-side maintenance.

◆ transaction()

auto db::SqliteCppDb::transaction ( ) -> Transaction

The documentation for this class was generated from the following files: