KQLite Pragma
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
Properties
Queries or sets the analysis_limit for the query planner.
Queries or sets the application_id.
Queries or sets the automatic_index flag.
Queries or set the auto-vacuum mode.
Queries or sets the busy_timeout in milliseconds.
Queries or sets the suggested maximum number of database disk pages that SQLite will hold in memory at one time per open database file.
Queries or sets the cache_spill setting.
Queries or sets the case_sensitive_like flag.
Queries or sets the cell_size_check flag.
Queries or sets the checkpoint_fullfsync flag.
Queries a list of all collating sequences defined for the current database connection.
Queries a list of the compile-time options used to build the SQLite library.
Queries a list of all attached databases.
Queries the data_version of the database.
Queries or sets the defer_foreign_keys flag.
Queries or sets the text encoding for the main database.
Queries or sets the enforcement of foreign key constraints.
Queries the number of unused pages in the database file's freelist.
Queries or sets the fullfsync flag.
Queries a list of all SQL functions known to the database connection.
Queries or sets the hard upper bound on the amount of memory that can be allocated by SQLite.
Queries or sets the ignore_check_constraints flag.
Queries or sets the journal mode for the database.
Queries or sets the maximum size limit for the rollback journal file in bytes.
Queries or sets the legacy_alter_table flag.
Queries or sets the legacy_file_format flag.
Queries or sets the database connection's locking mode.
Queries or sets the maximum number of pages in the database file.
Queries or sets the maximum size of the memory-mapped I/O region in bytes.
Queries a list of all registered virtual table modules.
Queries the total number of pages in the database file.
Queries or sets the size of the database pages in bytes.
Queries a list of all pragma statements supported by the current version of SQLite.
Queries or sets the query_only flag.
Queries or sets the read_uncommitted isolation level.
Queries or sets the recursive_triggers flag.
Queries or sets the reverse_unordered_selects flag.
Queries or sets the schema_version of the database.
Queries or sets the secure_delete flag, which controls how content is deleted from the database.
Queries or sets the soft heap limit for the SQLite memory allocator.
Queries or sets the disk synchronization strategy.
Queries a list of all tables and views in the main database schema.
Queries or sets where temporary tables and indices are stored.
Queries or sets the directory where temporary files are stored.
Queries or sets the suggested number of threads for the background thread pool.
Queries or sets the trusted_schema flag.
Queries or sets the application-defined user_version number.
Queries or sets the automatic checkpoint threshold in WAL mode.
Queries or sets the writable_schema flag, which allows direct modification of the internal schema tables (like sqlite_schema).
Functions
Checks for foreign key violations in the database.
Retrieves a list of all foreign key constraints for a given table.
Retrieves information about the columns of a specific index.
Retrieves a list of all indices associated with a given table.
Retrieves extended information about the columns of a specific index.
Performs a comprehensive integrity check of the database or a specific table.
A convenience function that performs an integrity check and returns a boolean indicating success.
A convenience function that performs a quick integrity check and returns a boolean indicating success.
Runs database optimization tasks.
Performs a faster, less thorough integrity check of the database or a specific table.
Attempts to free up memory that is no longer needed by the database connection.
Retrieves detailed information about the columns of a specific table.
Retrieves extended information about the columns of a specific table, including hidden columns.
Executes a WAL (Write-Ahead Log) checkpoint operation.