Pro.SQLite
— API for handling SQLite3 databases¶
Overview¶
The Pro.SQLite
module contains the API for handling SQLite3 databases.
Module API¶
Pro.SQLite module API.
Attributes:
Result code indicating that the SQL statement execution was aborted.
Result code indicating that authorization was denied.
Data type code for a value that is a BLOB (binary large object).
Result code indicating that the database file is locked and the requested operation could not be completed.
Result code indicating that the database file could not be opened.
Result code indicating that a constraint violation occurred (e.g., a UNIQUE constraint failed).
Result code indicating that the database disk image is malformed.
Result code indicating that the SQL statement has finished executing successfully.
Result code indicating an empty database (internal use only).
Generic error code indicating that an error occurred.
Data type code for a floating-point value.
Result code indicating an auxiliary database format error.
Result code indicating that an insertion failed because the database is full.
Data type code for a signed integer value.
Result code indicating an internal logic error in SQLite.
Result code indicating that the operation was terminated by sqlite3_interrupt().
Result code indicating that an I/O error occurred.
Result code indicating that a table in the database is locked.
Result code indicating a data type mismatch.
Result code indicating that the SQLite library was used incorrectly.
Result code indicating that the underlying operating system does not support large files.
Result code indicating that a memory allocation failed.
Result code indicating that the file opened is not a database file.
Result code indicating that an unknown opcode was given in sqlite3_file_control().
Data type code for a NULL value.
Result code indicating that the operation completed successfully.
Flag for sqlite3_open_v2(); deprecated and not used.
Flag indicating that the database should be created if it does not already exist.
Flag indicating that the database file should be deleted when it is closed.
Flag indicating that the database should be opened exclusively.
Flag indicating that the database connection should be opened in full mutex mode.
Flag indicating that the database file is the main database.
Flag indicating that the database file is the main journal.
Flag indicating that the database is an in-memory database.
Flag indicating that the open should not follow symbolic links.
Flag indicating that the database connection should be opened in no mutex mode.
Flag indicating that the database connection should use a private cache.
Flag indicating that the database is opened in read-only mode.
Flag indicating that the database is opened for reading and writing.
Flag indicating that the database connection should use shared cache.
Flag indicating that the database file is a sub-journal.
Flag indicating that the database file is a super-journal.
Flag indicating that the database file is a temporary database.
Flag indicating that the database file is a temporary journal.
Flag indicating that the database file is a transient database.
Flag indicating that the filename is interpreted as a URI.
Flag indicating that the database should be opened in WAL mode.
Result code indicating that access permission is denied.
Result code indicating a database lock protocol error.
Result code indicating that a parameter index is out of range.
Result code indicating that an attempt was made to write to a read-only database.
Result code indicating that sqlite3_step() has another row ready.
Result code indicating that the database schema has changed.
Data type code for a text string.
Result code indicating that a string or BLOB exceeds the size limit.
Functions:
sqlite3_bind_blob
(stmt, i, blob)Binds a BLOB value to a prepared statement parameter.
sqlite3_bind_double
(stmt, i, v)Binds a floating-point value to a prepared statement parameter.
sqlite3_bind_int
(stmt, i, v)Binds an integer value to a prepared statement parameter.
sqlite3_bind_int64
(stmt, i, v)Binds a 64-bit integer value to a prepared statement parameter.
sqlite3_bind_null
(stmt, i)Binds a NULL value to a prepared statement parameter.
Returns the number of SQL parameters in a prepared statement.
sqlite3_bind_parameter_index
(stmt, name)Returns the index of a parameter with the given name in a prepared statement.
sqlite3_bind_parameter_name
(stmt, i)Returns the name of a parameter at a given index in a prepared statement.
sqlite3_bind_text
(stmt, i, text)Binds a text string value to a prepared statement parameter.
sqlite3_bind_zeroblob
(stmt, i, n)Binds a BLOB of zero-filled bytes to a prepared statement parameter.
sqlite3_changes
(db)Returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement on the database connection.
sqlite3_clear_bindings
(stmt)Resets all parameters in a prepared statement to NULL.
sqlite3_close
(db)Closes a database connection.
sqlite3_column_blob
(stmt, col)Returns the value of a column in the current result row as a BLOB.
sqlite3_column_bytes
(stmt, col)Returns the size in bytes of the column value in the current result row.
sqlite3_column_count
(stmt)Returns the number of columns in the result set of the prepared statement.
sqlite3_column_decltype
(stmt, i)Returns the declared type of a table column.
sqlite3_column_double
(stmt, col)Returns the value of a column in the current result row as a floating-point number.
sqlite3_column_int
(stmt, col)Returns the value of a column in the current result row as an integer.
sqlite3_column_int64
(stmt, col)Returns the value of a column in the current result row as a 64-bit integer.
sqlite3_column_name
(stmt, i)Returns the name of a column in the result set.
sqlite3_column_text
(stmt, col)Returns the value of a column in the current result row as a text string.
sqlite3_column_type
(stmt, col)Returns the data type code for the value of a column in the current result row.
sqlite3_complete
(sql)Checks whether a string of SQL contains one or more complete SQL statements.
sqlite3_data_count
(stmt)Returns the number of columns in the current result row.
sqlite3_errcode
(db)Returns the numeric result code for the most recent failed SQLite API call associated with a database connection.
sqlite3_errmsg
(db)Returns the error message corresponding to the most recent failed SQLite API call associated with a database connection.
sqlite3_exec
(db, sql)Executes one or more SQL statements.
Returns the extended numeric result code for the most recent failed SQLite API call associated with a database connection.
sqlite3_finalize
(stmt)Destroys a prepared statement object.
Returns the row ID of the most recent successful INSERT into a rowid table.
Returns the SQLite library version as a string.
Returns the SQLite library version as an integer.
sqlite3_open
(file_name)Opens a new database connection.
sqlite3_open_v2
(file_name, flags, vfs)Opens a new database connection with extended options.
sqlite3_prepare
(db, sql)Compiles an SQL statement into a prepared statement.
sqlite3_reset
(stmt)Resets a prepared statement object back to its initial state, ready to be re-executed.
Returns a string identifying the source code used to build SQLite.
sqlite3_sql
(stmt)Returns the SQL text used to create a prepared statement.
sqlite3_step
(stmt)Evaluates a prepared statement one step (row) at a time.
sqlite3_stmt_busy
(stmt)Checks if a prepared statement has been stepped but not reset or finalized.
sqlite3_stmt_readonly
(stmt)Checks if a prepared statement makes no direct changes to the content of the database file.
Returns the total number of rows inserted, updated, or deleted by all SQL statements executed on the database connection.
Returns the SQLite library version as a string.
- SQLITE_ABORT: Final[int]¶
Result code indicating that the SQL statement execution was aborted.
- SQLITE_AUTH: Final[int]¶
Result code indicating that authorization was denied.
- SQLITE_BLOB: Final[int]¶
Data type code for a value that is a BLOB (binary large object).
- SQLITE_BUSY: Final[int]¶
Result code indicating that the database file is locked and the requested operation could not be completed.
- SQLITE_CANTOPEN: Final[int]¶
Result code indicating that the database file could not be opened.
- SQLITE_CONSTRAINT: Final[int]¶
Result code indicating that a constraint violation occurred (e.g., a UNIQUE constraint failed).
- SQLITE_CORRUPT: Final[int]¶
Result code indicating that the database disk image is malformed.
- SQLITE_DONE: Final[int]¶
Result code indicating that the SQL statement has finished executing successfully.
- SQLITE_EMPTY: Final[int]¶
Result code indicating an empty database (internal use only).
- SQLITE_ERROR: Final[int]¶
Generic error code indicating that an error occurred.
- SQLITE_FLOAT: Final[int]¶
Data type code for a floating-point value.
- SQLITE_FORMAT: Final[int]¶
Result code indicating an auxiliary database format error.
- SQLITE_FULL: Final[int]¶
Result code indicating that an insertion failed because the database is full.
- SQLITE_INTEGER: Final[int]¶
Data type code for a signed integer value.
- SQLITE_INTERNAL: Final[int]¶
Result code indicating an internal logic error in SQLite.
- SQLITE_INTERRUPT: Final[int]¶
Result code indicating that the operation was terminated by sqlite3_interrupt().
- SQLITE_IOERR: Final[int]¶
Result code indicating that an I/O error occurred.
- SQLITE_LOCKED: Final[int]¶
Result code indicating that a table in the database is locked.
- SQLITE_MISMATCH: Final[int]¶
Result code indicating a data type mismatch.
- SQLITE_MISUSE: Final[int]¶
Result code indicating that the SQLite library was used incorrectly.
- SQLITE_NOLFS: Final[int]¶
Result code indicating that the underlying operating system does not support large files.
- SQLITE_NOMEM: Final[int]¶
Result code indicating that a memory allocation failed.
- SQLITE_NOTADB: Final[int]¶
Result code indicating that the file opened is not a database file.
- SQLITE_NOTFOUND: Final[int]¶
Result code indicating that an unknown opcode was given in sqlite3_file_control().
- SQLITE_NULL: Final[int]¶
Data type code for a NULL value.
- SQLITE_OK: Final[int]¶
Result code indicating that the operation completed successfully.
- SQLITE_OPEN_AUTOPROXY: Final[int]¶
Flag for sqlite3_open_v2(); deprecated and not used.
- SQLITE_OPEN_CREATE: Final[int]¶
Flag indicating that the database should be created if it does not already exist.
- SQLITE_OPEN_DELETEONCLOSE: Final[int]¶
Flag indicating that the database file should be deleted when it is closed.
- SQLITE_OPEN_EXCLUSIVE: Final[int]¶
Flag indicating that the database should be opened exclusively.
- SQLITE_OPEN_FULLMUTEX: Final[int]¶
Flag indicating that the database connection should be opened in full mutex mode.
- SQLITE_OPEN_MAIN_DB: Final[int]¶
Flag indicating that the database file is the main database.
- SQLITE_OPEN_MAIN_JOURNAL: Final[int]¶
Flag indicating that the database file is the main journal.
- SQLITE_OPEN_MEMORY: Final[int]¶
Flag indicating that the database is an in-memory database.
- SQLITE_OPEN_NOFOLLOW: Final[int]¶
Flag indicating that the open should not follow symbolic links.
- SQLITE_OPEN_NOMUTEX: Final[int]¶
Flag indicating that the database connection should be opened in no mutex mode.
- SQLITE_OPEN_PRIVATECACHE: Final[int]¶
Flag indicating that the database connection should use a private cache.
- SQLITE_OPEN_READONLY: Final[int]¶
Flag indicating that the database is opened in read-only mode.
- SQLITE_OPEN_READWRITE: Final[int]¶
Flag indicating that the database is opened for reading and writing.
- SQLITE_OPEN_SHAREDCACHE: Final[int]¶
Flag indicating that the database connection should use shared cache.
- SQLITE_OPEN_SUBJOURNAL: Final[int]¶
Flag indicating that the database file is a sub-journal.
- SQLITE_OPEN_SUPER_JOURNAL: Final[int]¶
Flag indicating that the database file is a super-journal.
- SQLITE_OPEN_TEMP_DB: Final[int]¶
Flag indicating that the database file is a temporary database.
- SQLITE_OPEN_TEMP_JOURNAL: Final[int]¶
Flag indicating that the database file is a temporary journal.
- SQLITE_OPEN_TRANSIENT_DB: Final[int]¶
Flag indicating that the database file is a transient database.
- SQLITE_OPEN_URI: Final[int]¶
Flag indicating that the filename is interpreted as a URI.
- SQLITE_OPEN_WAL: Final[int]¶
Flag indicating that the database should be opened in WAL mode.
- SQLITE_PERM: Final[int]¶
Result code indicating that access permission is denied.
- SQLITE_PROTOCOL: Final[int]¶
Result code indicating a database lock protocol error.
- SQLITE_RANGE: Final[int]¶
Result code indicating that a parameter index is out of range.
- SQLITE_READONLY: Final[int]¶
Result code indicating that an attempt was made to write to a read-only database.
- SQLITE_ROW: Final[int]¶
Result code indicating that sqlite3_step() has another row ready.
- SQLITE_SCHEMA: Final[int]¶
Result code indicating that the database schema has changed.
- SQLITE_TEXT: Final[int]¶
Data type code for a text string.
- SQLITE_TOOBIG: Final[int]¶
Result code indicating that a string or BLOB exceeds the size limit.
- sqlite3_bind_blob(stmt: sqlite3_stmt, i: int, blob: bytes) → int¶
Binds a BLOB value to a prepared statement parameter.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to which the value will be bound.
i (int) – Index of the SQL parameter to be set (starting from 1).
blob (bytes) – The BLOB data to bind to the parameter.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_bind_text()
,sqlite3_bind_double()
, andsqlite3_bind_int()
.
- sqlite3_bind_double(stmt: sqlite3_stmt, i: int, v: float) → int¶
Binds a floating-point value to a prepared statement parameter.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to which the value will be bound.
i (int) – Index of the SQL parameter to be set (starting from 1).
v (float) – The floating-point value to bind to the parameter.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_bind_int()
,sqlite3_bind_text()
, andsqlite3_bind_blob()
.
- sqlite3_bind_int(stmt: sqlite3_stmt, i: int, v: int) → int¶
Binds an integer value to a prepared statement parameter.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to which the value will be bound.
i (int) – Index of the SQL parameter to be set (starting from 1).
v (int) – The integer value to bind to the parameter.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_bind_double()
,sqlite3_bind_text()
, andsqlite3_bind_blob()
.
- sqlite3_bind_int64(stmt: sqlite3_stmt, i: int, v: sqlite3_int64) → int¶
Binds a 64-bit integer value to a prepared statement parameter.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to which the value will be bound.
i (int) – Index of the SQL parameter to be set (starting from 1).
v (sqlite3_int64) – The 64-bit integer value to bind to the parameter.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_bind_int()
,sqlite3_bind_double()
, andsqlite3_bind_text()
.
- sqlite3_bind_null(stmt: sqlite3_stmt, i: int) → int¶
Binds a NULL value to a prepared statement parameter.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to which the value will be bound.
i (int) – Index of the SQL parameter to be set (starting from 1).
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_bind_text()
,sqlite3_bind_double()
, andsqlite3_bind_int()
.
- sqlite3_bind_parameter_count(stmt: sqlite3_stmt) → int¶
Returns the number of SQL parameters in a prepared statement.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
- Returns
Number of parameters in the prepared statement.
- Return type
int
See also
sqlite3_bind_parameter_name()
andsqlite3_bind_parameter_index()
.
- sqlite3_bind_parameter_index(stmt: sqlite3_stmt, name: str) → int¶
Returns the index of a parameter with the given name in a prepared statement.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
name (str) – The name of the parameter (e.g., “:param_name”).
- Returns
Index of the named parameter (starting from 1), or 0 if not found.
- Return type
int
See also
sqlite3_bind_parameter_count()
andsqlite3_bind_parameter_name()
.
- sqlite3_bind_parameter_name(stmt: sqlite3_stmt, i: int) → str¶
Returns the name of a parameter at a given index in a prepared statement.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
i (int) – Index of the parameter (starting from 1).
- Returns
Name of the parameter, or None if not named.
- Return type
str
See also
sqlite3_bind_parameter_index()
andsqlite3_bind_parameter_count()
.
- sqlite3_bind_text(stmt: sqlite3_stmt, i: int, text: str) → int¶
Binds a text string value to a prepared statement parameter.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to which the value will be bound.
i (int) – Index of the SQL parameter to be set (starting from 1).
text (str) – The text string to bind to the parameter.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_bind_blob()
,sqlite3_bind_double()
, andsqlite3_bind_int()
.
- sqlite3_bind_zeroblob(stmt: sqlite3_stmt, i: int, n: int) → int¶
Binds a BLOB of zero-filled bytes to a prepared statement parameter.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to which the value will be bound.
i (int) – Index of the SQL parameter to be set (starting from 1).
n (int) – The size in bytes of the zero-filled BLOB.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_bind_blob()
andsqlite3_bind_null()
.
- sqlite3_changes(db: sqlite3) → int¶
Returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement on the database connection.
- Parameters
db (sqlite3) – Database connection.
- Returns
Number of rows changed by the most recent SQL statement.
- Return type
int
See also
sqlite3_total_changes()
.
- sqlite3_clear_bindings(stmt: sqlite3_stmt) → int¶
Resets all parameters in a prepared statement to NULL.
- Parameters
stmt (sqlite3_stmt) – Prepared statement whose bindings are to be cleared.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
- sqlite3_close(db: sqlite3) → int¶
Closes a database connection.
- Parameters
db (sqlite3) – Database connection to be closed.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
- sqlite3_column_blob(stmt: sqlite3_stmt, col: int) → bytes¶
Returns the value of a column in the current result row as a BLOB.
- Parameters
stmt (sqlite3_stmt) – Prepared statement from which to retrieve the column value.
col (int) – Zero-based index of the column.
- Returns
The column value as bytes (BLOB), or None if the value is NULL.
- Return type
bytes
See also
sqlite3_column_text()
,sqlite3_column_int()
, andsqlite3_column_double()
.
- sqlite3_column_bytes(stmt: sqlite3_stmt, col: int) → int¶
Returns the size in bytes of the column value in the current result row.
- Parameters
stmt (sqlite3_stmt) – Prepared statement from which to retrieve the column size.
col (int) – Zero-based index of the column.
- Returns
Size in bytes of the column value.
- Return type
int
See also
sqlite3_column_blob()
andsqlite3_column_text()
.
- sqlite3_column_count(stmt: sqlite3_stmt) → int¶
Returns the number of columns in the result set of the prepared statement.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
- Returns
Number of columns in the result set.
- Return type
int
- sqlite3_column_decltype(stmt: sqlite3_stmt, i: int) → str¶
Returns the declared type of a table column.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
i (int) – Zero-based index of the column.
- Returns
Declared data type of the column, or None if not declared.
- Return type
str
See also
sqlite3_column_name()
.
- sqlite3_column_double(stmt: sqlite3_stmt, col: int) → float¶
Returns the value of a column in the current result row as a floating-point number.
- Parameters
stmt (sqlite3_stmt) – Prepared statement from which to retrieve the column value.
col (int) – Zero-based index of the column.
- Returns
The column value as a float.
- Return type
float
See also
sqlite3_column_int()
,sqlite3_column_text()
, andsqlite3_column_blob()
.
- sqlite3_column_int(stmt: sqlite3_stmt, col: int) → int¶
Returns the value of a column in the current result row as an integer.
- Parameters
stmt (sqlite3_stmt) – Prepared statement from which to retrieve the column value.
col (int) – Zero-based index of the column.
- Returns
The column value as an int.
- Return type
int
See also
sqlite3_column_double()
,sqlite3_column_text()
, andsqlite3_column_blob()
.
- sqlite3_column_int64(stmt: sqlite3_stmt, col: int) → sqlite3_int64¶
Returns the value of a column in the current result row as a 64-bit integer.
- Parameters
stmt (sqlite3_stmt) – Prepared statement from which to retrieve the column value.
col (int) – Zero-based index of the column.
- Returns
The column value as a 64-bit integer.
- Return type
sqlite3_int64
See also
sqlite3_column_int()
,sqlite3_column_double()
, andsqlite3_column_text()
.
- sqlite3_column_name(stmt: sqlite3_stmt, i: int) → str¶
Returns the name of a column in the result set.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
i (int) – Zero-based index of the column.
- Returns
Name of the column.
- Return type
str
See also
sqlite3_column_decltype()
.
- sqlite3_column_text(stmt: sqlite3_stmt, col: int) → str¶
Returns the value of a column in the current result row as a text string.
- Parameters
stmt (sqlite3_stmt) – Prepared statement from which to retrieve the column value.
col (int) – Zero-based index of the column.
- Returns
The column value as a string.
- Return type
str
See also
sqlite3_column_blob()
,sqlite3_column_int()
, andsqlite3_column_double()
.
- sqlite3_column_type(stmt: sqlite3_stmt, col: int) → int¶
Returns the data type code for the value of a column in the current result row.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
col (int) – Zero-based index of the column.
- Returns
Data type code of the column value (e.g.,
SQLITE_INTEGER
,SQLITE_TEXT
).- Return type
int
See also
sqlite3_column_blob()
,sqlite3_column_text()
, andsqlite3_column_int()
.
- sqlite3_complete(sql: str) → int¶
Checks whether a string of SQL contains one or more complete SQL statements.
- Parameters
sql (str) – SQL statement(s) to check.
- Returns
Non-zero if the input contains a complete SQL statement; zero otherwise.
- Return type
int
- sqlite3_data_count(stmt: sqlite3_stmt) → int¶
Returns the number of columns in the current result row.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
- Returns
Number of columns in the current row.
- Return type
int
- sqlite3_errcode(db: sqlite3) → int¶
Returns the numeric result code for the most recent failed SQLite API call associated with a database connection.
- Parameters
db (sqlite3) – Database connection.
- Returns
Numeric result code (e.g.,
SQLITE_OK
,SQLITE_ERROR
).- Return type
int
See also
sqlite3_errmsg()
andsqlite3_extended_errcode()
.
- sqlite3_errmsg(db: sqlite3) → str¶
Returns the error message corresponding to the most recent failed SQLite API call associated with a database connection.
- Parameters
db (sqlite3) – Database connection.
- Returns
Error message string.
- Return type
str
See also
sqlite3_errcode()
.
- sqlite3_exec(db: sqlite3, sql: str) → int¶
Executes one or more SQL statements.
- Parameters
db (sqlite3) – Database connection.
sql (str) – SQL statements to execute.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
See also
sqlite3_prepare()
andsqlite3_step()
.
- sqlite3_extended_errcode(db: sqlite3) → int¶
Returns the extended numeric result code for the most recent failed SQLite API call associated with a database connection.
- Parameters
db (sqlite3) – Database connection.
- Returns
Extended numeric result code.
- Return type
int
See also
sqlite3_errcode()
.
- sqlite3_finalize(stmt: sqlite3_stmt) → int¶
Destroys a prepared statement object.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to finalize.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
- sqlite3_last_insert_rowid(db: sqlite3) → sqlite3_int64¶
Returns the row ID of the most recent successful INSERT into a rowid table.
- Parameters
db (sqlite3) – Database connection.
- Returns
The row ID of the last inserted row.
- Return type
sqlite3_int64
- sqlite3_libversion() → str¶
Returns the SQLite library version as a string.
- Returns
SQLite library version string.
- Return type
str
- sqlite3_libversion_number() → int¶
Returns the SQLite library version as an integer.
- Returns
SQLite library version number.
- Return type
int
- sqlite3_open(file_name: str) → tuple[int, sqlite3]¶
Opens a new database connection.
- Parameters
file_name (str) – Name of the database file.
- Returns
Tuple containing the result code and the new database connection.
- Return type
tuple[int, sqlite3]
See also
sqlite3_close()
andsqlite3_open_v2()
.
- sqlite3_open_v2(file_name: str, flags: int, vfs: str) → tuple[int, sqlite3]¶
Opens a new database connection with extended options.
- Parameters
file_name (str) – Name of the database file.
flags (int) – Flags controlling the behavior of the database connection (e.g.,
SQLITE_OPEN_READWRITE
,SQLITE_OPEN_CREATE
).vfs (str) – Name of the virtual file system to use, or None to use the default.
- Returns
Tuple containing the result code and the new database connection.
- Return type
tuple[int, sqlite3]
See also
sqlite3_open()
.
- sqlite3_prepare(db: sqlite3, sql: str) → tuple[int, sqlite3_stmt]¶
Compiles an SQL statement into a prepared statement.
- Parameters
db (sqlite3) – Database connection.
sql (str) – SQL statement to compile.
- Returns
Tuple containing the result code and the prepared statement object.
- Return type
tuple[int, sqlite3_stmt]
See also
sqlite3_finalize()
andsqlite3_step()
.
- sqlite3_reset(stmt: sqlite3_stmt) → int¶
Resets a prepared statement object back to its initial state, ready to be re-executed.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to reset.
- Returns
Result code, typically
SQLITE_OK
on success.- Return type
int
- sqlite3_sourceid() → str¶
Returns a string identifying the source code used to build SQLite.
- Returns
SQLite source ID string.
- Return type
str
- sqlite3_sql(stmt: sqlite3_stmt) → str¶
Returns the SQL text used to create a prepared statement.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to inspect.
- Returns
Original SQL text used to create the prepared statement.
- Return type
str
- sqlite3_step(stmt: sqlite3_stmt) → int¶
Evaluates a prepared statement one step (row) at a time.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to execute.
- Returns
Result code, such as
SQLITE_ROW
(row ready) orSQLITE_DONE
(execution complete).- Return type
int
See also
sqlite3_prepare()
andsqlite3_finalize()
.
- sqlite3_stmt_busy(stmt: sqlite3_stmt) → int¶
Checks if a prepared statement has been stepped but not reset or finalized.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to check.
- Returns
Non-zero if the prepared statement is busy; zero otherwise.
- Return type
int
- sqlite3_stmt_readonly(stmt: sqlite3_stmt) → int¶
Checks if a prepared statement makes no direct changes to the content of the database file.
- Parameters
stmt (sqlite3_stmt) – Prepared statement to check.
- Returns
Non-zero if the statement is read-only; zero otherwise.
- Return type
int
- sqlite3_total_changes(db: sqlite3) → int¶
Returns the total number of rows inserted, updated, or deleted by all SQL statements executed on the database connection.
- Parameters
db (sqlite3) – Database connection.
- Returns
Total number of rows changed.
- Return type
int
See also
sqlite3_changes()
.
- sqlite3_version() → str¶
Returns the SQLite library version as a string.
- Returns
SQLite library version string.
- Return type
str
See also
sqlite3_libversion()
.