HFSQtLi 0.0.1
A Qt/C++ wrapper for SQLite3.

What is HFSQtLi

HFSQtLi is a Qt/C++ wrapper for SQLite3. It tries to use templating to make the use as intuitive as possible while at the same time mapping (almost) directly to just a few C calls to the right functions of SQLite API.

Examples of usage

Hello, world!

QString str;
auto *db=Db::open(":memory:", QIODevice::ReadWrite);
db->executeSingleAll <1> (
"SELECT \"Hello, \" || $1 || \"!\"; ",
"world",
str
);
qDebug()<<str; // Prints "Hello, world!"
static Db * open(const QString &filename, QIODevice::OpenMode flags=QIODevice::ReadWrite, QString *errorMsg=nullptr, const char *zVfs=nullptr)
open Opens a database
Definition: HFSQtLi.cpp:573

Fetching rows

Query qry(db);
if(db.prepare("SELECT a FROM testTable"))
{
QString val;
while(query.step(val))
qDebug()<<val;
}
Class that gives access to SQLite prepared statements (struct sqlite3_stmt)
Definition: HFSQtLi.h:539

Retriving error messages

Query qry(db);
if(qry.prepare("SLECT a FROM testTable")) // Note: invalid query string
{
...
}
else
qDebug()<<qry.errorMsg();

Custom data types

See examples of CustomBind and CustomFetch