How to use this reference

The following index links to per-class hdoc-style pages. Each page documents every constructor, method, constant, and public data member that appears in the corresponding header under include/sqlite/.

Because these files are checked into this repository, new classes automatically pick up a page the next time you regenerate the site.

Core API

Concurrency & pooling

Extensions & utilities

Error handling

Usage examples

Connections, commands, results

#include <sqlite/connection.hpp>
#include <sqlite/execute.hpp>
#include <sqlite/query.hpp>
#include <iostream>

sqlite::connection db("notes.db");
sqlite::execute(db, "CREATE TABLE IF NOT EXISTS notes(id INTEGER PRIMARY KEY, text TEXT);", true);

sqlite::execute insert(db, "INSERT INTO notes(text) VALUES(?);");
insert % "Hello";
insert();

sqlite::query q(db, "SELECT id, text FROM notes;");
for(auto & row : q.each()) {
    std::cout << '[' << row.get(0) << "] "
              << row.get(1) << '\n';
}

Demonstrates the connection, command, execute, query, and result pages above.

Pooling & threads

auto factory = sqlite::connection_pool::make_factory("jobs.db");
sqlite::connection_pool pool(4, factory);

auto worker = [&] {
    auto lease = pool.acquire();
    sqlite::execute(*lease, "INSERT INTO jobs(status) VALUES('done');");
};

std::thread t1(worker), t2(worker);
t1.join(); t2.join();

Relies on threading (configure before creating pools) and connection_pool.

JSON helpers & custom SQL functions

sqlite::json::register_contains_function(db);
sqlite::create_function(db, "double_text",
    [](std::string_view s) { return std::string(s) + s; },
    {.deterministic = true});

auto where = sqlite::json::contains_expression("payload", sqlite::json::path().key("tags"), "?");
std::string sql = "SELECT id FROM docs WHERE " + where + " AND double_text(title) = ?;";

Pulls together json_fts and function.