9#ifndef SL3_DATABASE_HPP_
10#define SL3_DATABASE_HPP_
15#include <sl3/command.hpp>
16#include <sl3/config.hpp>
17#include <sl3/dataset.hpp>
18#include <sl3/dbvalue.hpp>
42 class LIBSL3_API Database
45 Database (
const Database&) =
delete;
46 Database& operator= (
const Database&) =
delete;
47 Database& operator= (Database&&) =
delete;
71 explicit Database (
const std::string& name,
int openFlags = 0);
83 Database (Database&&) noexcept;
284 explicit Transaction (Database&);
285 friend class Database;
288 Transaction (
const Transaction&) =
delete;
289 Transaction& operator= (
const Transaction&) =
delete;
290 Transaction& operator= (Transaction&&) =
delete;
343 using ConnectionPtr =
std::shared_ptr<internal::Connection>;
354 ConnectionPtr _connection;
A compiled SQL command.
Definition command.hpp:40
Transaction Guard.
Definition database.hpp:281
void commit()
Commit the transaction.
Transaction(Transaction &&) noexcept
Move constructor A Transaction is movable.
Represents a SQLite3 database.
Definition database.hpp:43
Dataset select(const std::string &sql)
Execute a SQL query and return the result.
std::string getMostRecentErrMsg()
Returns most recent error message.
virtual ~Database() noexcept
Destructor.
Transaction beginTransaction()
Create a TransactionGuard.
int getMostRecentErrCode()
Returns last SQLite3 extended result code.
sqlite3 * db()
Access the underlying sqlite3 database.
std::size_t getTotalChanges()
Returns the number of rows that have changed since the database was opened.
std::size_t getRecentlyChanged()
Rows that have been changed from the most recent SQL statement.
int64_t getLastInsertRowid()
Returns the rowid of the most recent successful INSERT statement.
Command::Callback Callback
shortcut for Command::Callback
Definition database.hpp:142
DbValue selectValue(const std::string &sql)
Select a single value from the database.
Database(const std::string &name, int openFlags=0)
Constructor.
void execute(const std::string &sql)
Execute one or more SQL statements.
Command prepare(const std::string &sql)
Create an SQL command instance.
A utility for processing query results.
Definition dataset.hpp:48
This class models the duck typing sqlite uses. It supports int, real, text, blob and null values.
Definition dbvalue.hpp:43
A row of DbValues.
Definition dbvalues.hpp:30
Callback for SQL SELECT statements.
Definition rowcallback.hpp:30
A Container holding sl3::Type values.
Definition types.hpp:63
Namespace of libSL3.
Definition columns.hpp:18
std::string getErrStr(int errcode)
Wraps sqlite3_errstr() function.
Type
Definition types.hpp:30