|
HFSQtLi 0.0.1
A Qt/C++ wrapper for SQLite3.
|
Class that gives access to a SQLite connection (struct sqlite3). More...
#include <HFSQtLi.h>
Public Member Functions | |
| bool | isOk () const |
| isOk Check the status of the last operation on database More... | |
| int | error () const |
| error Check the error code from last operation on database More... | |
| QString | errorMsg () const |
| Query * | query (const char *queryStr, bool persistent=true, bool keepErrorMessage=true) |
| query Creates a new query More... | |
| QSharedPointer< Query > | queryRef (const char *queryStr, bool persistent=true, bool keepErrorMessage=true) |
| query Creates a new query More... | |
Commands query execution | |
The following function allows easy operation on any query that returns no row (e.g. CREATE TABLE or DELETE). See Query::executeCommand. | |
| template<typename... Args> | |
| int | execute (const QString &query, Args &&... args) |
| Executes a query returning no rows. See Query::executeCommand. More... | |
| template<typename... Args> | |
| int | execute (QString *error, const QString &query, Args &&... args) |
| Executes a query returning no rows, optionally returning the error message generated. See Query::executeCommand. More... | |
Single row query execution | |
The following function allows easy operation on any query that returns one and only one row. They perform in one operation binding of parameters, a step on first row, fetching the data of the row and a second step to check the query effetively returned only one row.
| |
| template<typename... Args> | |
| int | executeSingleAll (const QString &query, Args &&... args) |
| Execute a query returning just one row and fetches all of the returned data. More... | |
| template<int I, typename... Args> | |
| int | executeSingleAll (const QString &query, Args &&... args) |
| Execute a query returning just one row and fetches all of the returned data. More... | |
| template<int I, typename... Args> | |
| int | executeSingleAll (QString *error, const QString &query, Args &&... args) |
| Execute a query returning just one row and fetches all of the returned data. More... | |
Static Public Member Functions | |
| static Db * | open (const QString &filename, QIODevice::OpenMode flags=QIODevice::ReadWrite, QString *errorMsg=nullptr, const char *zVfs=nullptr) |
| open Opens a database More... | |
Protected Member Functions | |
| Db (const QString &filename, QIODevice::OpenMode flags=QIODevice::ReadWrite, const char *zVfs=NULL) | |
Protected Attributes | |
| sqlite3 * | m_db |
| std::atomic_int | m_queryCount |
| int | m_openError |
| QString | m_openErrorMsg |
Friends | |
| class | Query |
| class | Helper::BlobData |
Class that gives access to a SQLite connection (struct sqlite3).
No public constructor is available, instance of the class must be created via Db::open.
| int Db::error | ( | ) | const |
error Check the error code from last operation on database
|
inline |
Executes a query returning no rows. See Query::executeCommand.
|
inline |
Executes a query returning no rows, optionally returning the error message generated. See Query::executeCommand.
|
inline |
Execute a query returning just one row and fetches all of the returned data.
| I | Number of parameters to bind |
| strict | True if the data of the types should be checked |
| args | First I arguments are the values to bind (see Bounded data types), the ones after that are references to data to retrive (see Fetched data types) |
| query | A string containing the query to execute |
|
inline |
Execute a query returning just one row and fetches all of the returned data.
| I | Number of parameters to bind |
| strict | True if the data of the types should be checked |
| args | First I arguments are the values to bind (see Bounded data types), the ones after that are references to data to retrive (see Fetched data types) |
| query | A string containing the query to execute |
| int HFSQtLi::Db::executeSingleAll | ( | QString * | error, |
| const QString & | query, | ||
| Args &&... | args | ||
| ) |
Execute a query returning just one row and fetches all of the returned data.
| I | Number of parameters to bind |
| strict | True if the data of the types should be checked |
| args | First I arguments are the values to bind (see Bounded data types), the ones after that are references to data to retrive (see Fetched data types) |
| error | An optional pointer to a string to fill with the error message. |
| query | A string containing the query to execute |
| bool Db::isOk | ( | ) | const |
isOk Check the status of the last operation on database
|
static |
open Opens a database
| filename | Path to filename to open |
| An | or between flags QIODevice::ReadWrite for a read/write database and QIODevice::Append to open only an existing database |
| errorMsg | Pointer to a string that will be filled with error message in case of error |
| zVfs | Virtual file system to open (See SQLite documentation) |
| Query * Db::query | ( | const char * | queryStr, |
| bool | persistent = true, |
||
| bool | keepErrorMessage = true |
||
| ) |
query Creates a new query
| queryStr | Query string |
| persistent | Optimize persistent queries |
| keepErrorMessage | True if error message returned should be stored |
|
inline |