sqlite::execute inherits from sqlite::command but offers a simplified constructor that optionally executes immediately. Use it for DDL and DML statements when you do not need to iterate over result rows.

Use cases

  • Ideal for one-shot schema migrations—set immediately = true so the SQL runs as soon as the object is constructed.
  • Rebind and call operator() as many times as needed; under the hood it reuses the prepared statement stored in the connection’s statement cache.
  • Returns true from step_once() only when SQLite reports SQLITE_ROW, which usually indicates a trigger produced output.

Example usage

sqlite::execute migrate{
    db,
    R\"SQL(
        CREATE TABLE IF NOT EXISTS users(
            id INTEGER PRIMARY KEY,
            email TEXT NOT NULL UNIQUE,
            created_at INTEGER NOT NULL
        )
    )SQL\",
    true // run immediately
};

sqlite::execute insert{db, "INSERT INTO users(email, created_at) VALUES(?, ?)"};
insert % "dev@example.com" % sqlite::clock::now();
insert();

Nothing fancy happens here—execute literally inherits command, so all the binding helpers and error handling behave exactly the same.

Public API

MemberDescription
execute(connection& con, std::string const& sql, bool immediately = false) Prepares sql and, if immediately is true, runs step_once() inside the constructor.
~execute() Inherits command's destructor to finalize the statement.