SQLiteAccess๏
Inherits: RefCounted < Object
Wrapper class for SQLite databases.
Description๏
A wrapper class that lets you perform SQL statements on an SQLite database file.
Methods๏
Signals๏
query_profiled(query_string: String, execution_time_ns: int) ๐
Emitted when a query is profiled with execution time information.
query_progress() ๐
Emitted periodically during long-running queries to report progress.
row_updated(update_operation: int, db_name: String, table_name: String, rowid: int) ๐
Emitted when a row is inserted, updated, or deleted.
transaction_committed() ๐
Emitted when a transaction is committed.
transaction_rolled_back() ๐
Emitted when a transaction is rolled back.
wal_updated(db_name: String, pages_in_wal: int) ๐
Emitted when the WAL file is updated.
Method Descriptions๏
bool backup(path: String) ๐
Creates a backup of the database at the location specified by path.
Returns true if the operation succeeds.
SQLiteBackup backup_async(path: String) ๐
Creates an asynchronous backup of the database to path.
Returns a SQLiteBackup object used to monitor and control the operation.
Closes the database connection and releases all associated resources.
Returns true if the database was successfully closed.
bool create_collation(name: String, callable: Callable) ๐
Creates a custom collation function named name using callable for string comparison logic.
bool create_function(name: String, argc: int, callable: Callable) ๐
Registers a custom SQL function named name that accepts argc arguments and executes callable.
SQLiteQuery create_query(statement: String, arguments: Array = []) ๐
Creates a prepared SQL query using statement and optional arguments.
bool enable_load_extension(enabled: bool) ๐
Enables or disables the ability to load SQLite extensions.
bool execute_script(path: String) ๐
Executes an SQL script located at path.
Returns true if execution succeeds.
Returns the number of rows affected by the most recent SQL statement.
String get_database_filename(db_name: String = "main") const ๐
Returns the filename associated with the database identified by db_name.
int get_db_config(op: int) const ๐
Returns the current configuration value for the database option identified by op.
int get_db_status(op: int, reset: bool = false) const ๐
Returns the current database status counter for op.
If reset is true, the counter is reset after reading.
int get_global_status(op: int, reset: bool) static ๐
Returns a global SQLite status counter identified by op.
If reset is true, the counter is reset after reading.
int get_last_error_code() const ๐
Returns the last SQLite error code.
String get_last_error_message() const ๐
Returns the last SQLite error message.
int get_last_insert_rowid() const ๐
Returns the row ID of the last inserted row.
int get_limit(id: int) const ๐
Returns the SQLite limit value identified by id.
int get_total_changes() const ๐
Returns the total number of rows changed since the database was opened.
void interrupt() ๐
Interrupts any currently running query.
bool is_autocommit() const ๐
Returns true if the database is in autocommit mode.
bool is_readonly(db_name: String = "main") const ๐
Returns true if the database identified by db_name is read-only.
bool open(database: String) ๐
Opens the database file at database. Returns true on success.
If the path starts with res://, an in-memory or buffered version may be used automatically.
SQLiteBlob open_blob(db_name: String, table_name: String, column_name: String, rowid: int, read_write: bool = false) ๐
Opens a BLOB handle for incremental access to binary data stored in a table.
bool open_buffered(path: String, buffers: PackedByteArray, size: int) ๐
Opens a database from an in-memory buffer. Changes are not persisted to disk.
Opens a temporary in-memory database.
int release_memory(bytes: int) static ๐
Attempts to release up to bytes of memory used by SQLite.
bool restore(path: String) ๐
Restores the database from the file at path.
SQLiteBackup restore_async(path: String) ๐
Restores the database asynchronously from path.
void set_authorizer(callable: Callable) ๐
Sets an authorizer callback used to approve or deny SQL operations.
bool set_busy_timeout(ms: int) ๐
Sets the busy timeout in milliseconds.
bool set_db_config(op: int, val: int) ๐
Sets a database configuration option.
void set_foreign_keys_enabled(enabled: bool) ๐
Enables or disables foreign key enforcement.
int set_limit(id: int, new_val: int) ๐
Sets a SQLite runtime limit.
void set_progress_handler(instructions: int) ๐
Sets a progress handler invoked during long-running queries.
void set_soft_heap_limit(bytes: int) static ๐
Sets SQLite's soft heap memory limit.
void set_trace(enabled: bool) ๐
Enables or disables SQL tracing.
Rebuilds and optimizes the database file.
bool wal_checkpoint(db_name: String = "main") ๐
Performs a WAL checkpoint operation.