|
|
| SQLConn (SQLConn &&)=default |
| | Move constructor.
|
|
SQLConn & | operator= (SQLConn &&)=default |
| | Move assignment.
|
| bool | open (const std::filesystem::path &dbFile, unsigned int flags=0) |
| | Open a database connection (openDB() + createDB() + prepDB()).
|
| bool | openDB (const std::filesystem::path &dbFile, unsigned int flags=0) noexcept |
| | Just open a database file.
|
| virtual bool | createDB () |
| | Creates tables, views, triggers and such.
|
| virtual bool | prepDB () |
| | Prepares statements.
|
| bool | exec (const std::string &sql) const noexcept |
| | Execute sql.
|
| bool | attach (const std::filesystem::path &dbFile, std::string_view dbName) const noexcept |
| | Attach another database using ATTACH.
|
| bool | begin (TransactionType type=TransactionType::DEFERRED) const noexcept |
| | Begin a transaction.
|
| bool | end () const noexcept |
| | End a transaction.
|
| AutoTransaction | beginAuto (TransactionType type=TransactionType::DEFERRED) const noexcept |
| | Begin a transaction which is automatically ended when the returned object dies.
|
|
std::string | lastError () const |
| | Return the last error string if some.
|
|
int | lastErrorCode () const |
| | Return the last error number.
|
|
int | lastErrorCodeExt () const |
| | Return the last extended error number.
|
|
| enum | TableFlags : unsigned { TABLE_TEMPORARY = 1u << 0
} |
| | Flags for TableEntry::flags.
|
|
using | BindVal = std::variant<std::monostate, int, unsigned, std::string, std::string_view> |
| | Bind value (SQL's null, number, string).
|
|
using | Binding = std::vector<std::pair<std::string, BindVal>> |
| | Bind name -> bind value.
|
|
using | Column = std::variant<std::monostate, int, std::string> |
| | One column returned by SELECT.
|
|
using | Row = std::vector<Column> |
| | One row returned by SELECT (ie. list of Columns).
|
|
using | SelectResult = std::vector<Row> |
| | Complete SELECT result.
|
|
using | Tables = std::vector<TableEntry> |
| | Tables to be created by createTables().
|
|
using | Indices = std::vector<std::pair<std::string, std::string>> |
| | Indices to be created by createIndices().
|
|
using | Triggers = Indices |
| | Triggers to be created by createTriggers().
|
|
using | Views = Indices |
| | Views to be created by createViews().
|
|
using | Statements = std::vector<std::pair<std::reference_wrapper<SQLStmtHolder>, std::string>> |
| | Statements to be prepared by prepareStatements().
|
|
using | LastError = SlHelpers::LastErrorStream<int, int> |
| | Store a string + 2 ints.
|
|
|
bool | createTables (const Tables &tables) const noexcept |
| | Create tables in the DB as specified in tables.
|
|
bool | createIndices (const Indices &indices) const noexcept |
| | Create indices in the DB as specified in indices.
|
|
bool | createTriggers (const Triggers &triggers) const noexcept |
| | Create triggers in the DB as specified in triggers.
|
|
bool | createViews (const Views &views) const noexcept |
| | Create views in the DB as specified in views.
|
|
bool | prepareStatement (std::string_view sql, SQLStmtHolder &stmt) const noexcept |
| | Prepate one sql string into stmt.
|
|
bool | prepareStatements (const Statements &stmts) const noexcept |
| | Prepate all statements as specified in stmts.
|
|
bool | bind (const SQLStmtHolder &ins, const std::string &key, const BindVal &val, bool transient=false) const noexcept |
| | Bind one value val into key of the statement ins.
|
|
bool | bind (const SQLStmtHolder &ins, const Binding &binding, bool transient=false) const noexcept |
| | Bind one binding for the statement ins.
|
|
bool | step (const SQLStmtHolder &ins, uint64_t *affected=nullptr, bool *uniqueError=nullptr) const noexcept |
| | Do one step of the statement ins.
|
|
bool | insert (const SQLStmtHolder &ins, const Binding &binding={}, uint64_t *affected=nullptr) const noexcept |
| | Bind, step, and reset the statement ins, using the passed binding.
|
|
std::optional< SQLConn::SelectResult > | select (const SQLStmtHolder &sel, const Binding &binding) const noexcept |
| | Perform one SELECT (sel), using the passed binding.
|
|
LastError & | setError (int ret, std::string_view error, bool errmsg=false) const |
| | Set last error to ret and error.
|
SQLite3 connection (the core class).