KQLitePragma

sealed class KQLitePragma(con: SQLiteConnection)

Provides a type-safe and convenient API for interacting with SQLite PRAGMA statements.

This class encapsulates various PRAGMA commands and functions, allowing developers to query and modify the internal state and operational parameters of the SQLite database connection without writing raw SQL. It offers properties for simple value-based pragmas (like journal_mode) and methods for pragmas that return cursors or require arguments (like table_info).

For detailed information on each PRAGMA, refer: SQLite PRAGMA Docs

Example

// Inside KQLiteDatabase
override fun onConfigure(pragma: KQLitePragma) {
// Get the current journal mode
val currentMode = pragma.journalMode.get()
println("Journal mode is: $currentMode")

// Set a new journal mode
pragma.journalMode.set(JournalMode.WAL)

// Check if foreign keys are enabled
val areForeignKeysOn = pragma.foreignKeys.get()

// Get information about a table
val tableInfoCursor = pragma.tableInfo(myTable)
tableInfoCursor.use { cursor ->
while (cursor.hasNext()) {
val row = cursor.next()
// process row data
}
}
}

Author

MOHAMMAD AZIM ANSARI

See also

Constructors

Link copied to clipboard
protected constructor(con: SQLiteConnection)

Properties

Link copied to clipboard

Queries or sets the analysis_limit for the query planner.

Link copied to clipboard

Queries or sets the application_id.

Link copied to clipboard

Queries or sets the automatic_index flag.

Link copied to clipboard

Queries or set the auto-vacuum mode.

Link copied to clipboard

Queries or sets the busy_timeout in milliseconds.

Link copied to clipboard

Queries or sets the suggested maximum number of database disk pages that SQLite will hold in memory at one time per open database file.

Link copied to clipboard

Queries or sets the cache_spill setting.

Link copied to clipboard

Queries or sets the case_sensitive_like flag.

Link copied to clipboard

Queries or sets the cell_size_check flag.

Link copied to clipboard

Queries or sets the checkpoint_fullfsync flag.

Link copied to clipboard

Queries a list of all collating sequences defined for the current database connection.

Link copied to clipboard

Queries a list of the compile-time options used to build the SQLite library.

Link copied to clipboard

Queries a list of all attached databases.

Link copied to clipboard

Queries the data_version of the database.

Link copied to clipboard

Queries or sets the defer_foreign_keys flag.

Link copied to clipboard

Queries or sets the text encoding for the main database.

Link copied to clipboard

Queries or sets the enforcement of foreign key constraints.

Link copied to clipboard

Queries the number of unused pages in the database file's freelist.

Link copied to clipboard

Queries or sets the fullfsync flag.

Link copied to clipboard

Queries a list of all SQL functions known to the database connection.

Link copied to clipboard

Queries or sets the hard upper bound on the amount of memory that can be allocated by SQLite.

Link copied to clipboard

Queries or sets the ignore_check_constraints flag.

Link copied to clipboard

Queries or sets the journal mode for the database.

Link copied to clipboard

Queries or sets the maximum size limit for the rollback journal file in bytes.

Link copied to clipboard

Queries or sets the legacy_alter_table flag.

Link copied to clipboard

Queries or sets the legacy_file_format flag.

Link copied to clipboard

Queries or sets the database connection's locking mode.

Link copied to clipboard

Queries or sets the maximum number of pages in the database file.

Link copied to clipboard

Queries or sets the maximum size of the memory-mapped I/O region in bytes.

Link copied to clipboard

Queries a list of all registered virtual table modules.

Link copied to clipboard

Queries the total number of pages in the database file.

Link copied to clipboard

Queries or sets the size of the database pages in bytes.

Link copied to clipboard

Queries a list of all pragma statements supported by the current version of SQLite.

Link copied to clipboard

Queries or sets the query_only flag.

Link copied to clipboard

Queries or sets the read_uncommitted isolation level.

Link copied to clipboard

Queries or sets the recursive_triggers flag.

Link copied to clipboard

Queries or sets the reverse_unordered_selects flag.

Link copied to clipboard

Queries or sets the schema_version of the database.

Link copied to clipboard

Queries or sets the secure_delete flag, which controls how content is deleted from the database.

Link copied to clipboard

Queries or sets the soft heap limit for the SQLite memory allocator.

Link copied to clipboard

Queries or sets the disk synchronization strategy.

Link copied to clipboard

Queries a list of all tables and views in the main database schema.

Link copied to clipboard

Queries or sets where temporary tables and indices are stored.

Link copied to clipboard

Queries or sets the directory where temporary files are stored.

Link copied to clipboard

Queries or sets the suggested number of threads for the background thread pool.

Link copied to clipboard

Queries or sets the trusted_schema flag.

Link copied to clipboard

Queries or sets the application-defined user_version number.

Link copied to clipboard

Queries or sets the automatic checkpoint threshold in WAL mode.

Link copied to clipboard

Queries or sets the writable_schema flag, which allows direct modification of the internal schema tables (like sqlite_schema).

Functions

Link copied to clipboard

Checks for foreign key violations in the database.

Link copied to clipboard

Retrieves a list of all foreign key constraints for a given table.

Link copied to clipboard
fun indexInfo(indexName: String): KQLiteCursor

Retrieves information about the columns of a specific index.

Link copied to clipboard

Retrieves a list of all indices associated with a given table.

Link copied to clipboard
fun indexXInfo(indexName: String): KQLiteCursor

Retrieves extended information about the columns of a specific index.

Link copied to clipboard

Performs a comprehensive integrity check of the database or a specific table.

Link copied to clipboard

A convenience function that performs an integrity check and returns a boolean indicating success.

Link copied to clipboard

A convenience function that performs a quick integrity check and returns a boolean indicating success.

Link copied to clipboard

Runs database optimization tasks.

Link copied to clipboard

Performs a faster, less thorough integrity check of the database or a specific table.

Link copied to clipboard

Attempts to free up memory that is no longer needed by the database connection.

Link copied to clipboard

Retrieves detailed information about the columns of a specific table.

Link copied to clipboard

Retrieves extended information about the columns of a specific table, including hidden columns.

Link copied to clipboard

Executes a WAL (Write-Ahead Log) checkpoint operation.