sql.sqlite.statement
import sql.sqlite.statement
sqllifts part of this module out to its own top level; each name below is shown with the path that reaches it. Anything still spelledsql.sqlite.statement.*needsimport sql.sqlite.statement.
A SQLite statement compiled once and run many times.
Compiling a statement is the expensive half of running one, and a statement run in a loop pays that cost once here rather than on every pass. The saving is real enough to be worth the extra object: an insert of ten thousand rows through a prepared statement does one compile instead of ten thousand.
A statement holds one native handle, so it can only be doing one thing at a time. Opening a cursor over it takes that handle until the cursor closes, and running it again in the meantime raises rather than silently resetting the cursor underneath.
Functions
describe()
sql.sqlite.statement.describe(statement) -> dict
Describes the columns a compiled statement returns.
Parameters
ptr— statement
Returns dict — { columns, conversions }
bind_all()
sql.sqlite.statement.bind_all(statement, values: list, query: string)
Binds values to a reset statement, in order.
Parameters
ptr— statementvalues(list)query(string) — For error messages.
Raises QueryError if the count does not match what the statement
expects.
Classes
SqliteStatement
class sql.sqlite.SqliteStatement < DriverStatement
A prepared SQLite statement.
- printable — has a
@to_string(), soechoandprint()show something useful
Constructor
sql.sqlite.SqliteStatement(connection, statement, query)
Parameters
connection(SqliteConnection) — The connection that owns this.ptr— statement The compiled native statement.query(string) — The statement text, as sent to the engine.
SqliteStatement.columns()
sql.sqlite.SqliteStatement.columns()
SqliteStatement.parameter_count()
sql.sqlite.SqliteStatement.parameter_count()
SqliteStatement.execute()
sql.sqlite.SqliteStatement.execute(values: list) -> dict
Runs the statement for its effect.
Parameters
values(list)
Returns dict — { rows_affected, last_insert_id }
SqliteStatement.select()
sql.sqlite.SqliteStatement.select(values: list) -> dict
Runs the statement and reads its whole result.
Parameters
values(list)
Returns dict — { columns, rows }
SqliteStatement.open_cursor()
sql.sqlite.SqliteStatement.open_cursor(values: list, options: dict) -> SqliteCursor
Runs the statement and hands back a cursor over its result.
The cursor holds this statement until it closes.
Parameters
values(list)options(dict) — Unused here; SQLite streams natively.
Returns SqliteCursor
SqliteStatement.close()
sql.sqlite.SqliteStatement.close()
Releases the statement. Safe to call more than once.
SqliteStatement.is_closed()
sql.sqlite.SqliteStatement.is_closed() -> bool
Whether this statement has been closed.
Returns bool
SqliteStatement.to_string()
sql.sqlite.SqliteStatement.to_string()
2026, Richard Ore and Zuri contributors