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๏ƒ

bool

backup(path: String)

SQLiteBackup

backup_async(path: String)

bool

close()

bool

create_collation(name: String, callable: Callable)

bool

create_function(name: String, argc: int, callable: Callable)

SQLiteQuery

create_query(statement: String, arguments: Array = [])

bool

enable_load_extension(enabled: bool)

bool

execute_script(path: String)

int

get_changes() const

String

get_database_filename(db_name: String = "main") const

int

get_db_config(op: int) const

int

get_db_status(op: int, reset: bool = false) const

int

get_global_status(op: int, reset: bool) static

int

get_last_error_code() const

String

get_last_error_message() const

int

get_last_insert_rowid() const

int

get_limit(id: int) const

int

get_total_changes() const

void

interrupt()

bool

is_autocommit() const

bool

is_readonly(db_name: String = "main") const

bool

open(database: String)

SQLiteBlob

open_blob(db_name: String, table_name: String, column_name: String, rowid: int, read_write: bool = false)

bool

open_buffered(path: String, buffers: PackedByteArray, size: int)

bool

open_in_memory()

int

release_memory(bytes: int) static

bool

restore(path: String)

SQLiteBackup

restore_async(path: String)

void

set_authorizer(callable: Callable)

bool

set_busy_timeout(ms: int)

bool

set_db_config(op: int, val: int)

void

set_foreign_keys_enabled(enabled: bool)

int

set_limit(id: int, new_val: int)

void

set_progress_handler(instructions: int)

void

set_soft_heap_limit(bytes: int) static

void

set_trace(enabled: bool)

bool

vacuum()

bool

wal_checkpoint(db_name: String = "main")


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.


bool close() ๐Ÿ”—

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.


int get_changes() const ๐Ÿ”—

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.


bool open_in_memory() ๐Ÿ”—

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.


bool vacuum() ๐Ÿ”—

Rebuilds and optimizes the database file.


bool wal_checkpoint(db_name: String = "main") ๐Ÿ”—

Performs a WAL checkpoint operation.