Pragma

Enum Pragma 

Source
pub enum Pragma {
Show 29 variants ApplicationId(i32), AutoVacuum(AutoVacuum), CacheSize(i32), ForeignKeys(bool), JournalMode(JournalMode), Synchronous(Synchronous), TempStore(TempStore), LockingMode(LockingMode), SecureDelete(SecureDelete), UserVersion(i32), Encoding(Encoding), PageSize(i32), MmapSize(i64), RecursiveTriggers(bool), CollationList, CompileOptions, DatabaseList, FunctionList, TableList, TableXInfo(&'static str), ModuleList, IntegrityCheck(Option<&'static str>), QuickCheck(Option<&'static str>), Optimize(Option<u32>), ForeignKeyCheck(Option<&'static str>), TableInfo(&'static str), IndexList(&'static str), IndexInfo(&'static str), ForeignKeyList(&'static str),
}
Expand description

SQLite pragma statements for database configuration and introspection

Variants§

§

ApplicationId(i32)

Set or query the 32-bit signed big-endian application ID

SQLite Documentation

§Example

let pragma = Pragma::ApplicationId(12345);
assert_eq!(pragma.to_sql().sql(), "PRAGMA application_id = 12345");
§

AutoVacuum(AutoVacuum)

Query or set the auto-vacuum status in the database

SQLite Documentation

§Example

let pragma = Pragma::AutoVacuum(AutoVacuum::Full);
assert_eq!(pragma.to_sql().sql(), "PRAGMA auto_vacuum = FULL");
§

CacheSize(i32)

Suggest maximum number of database disk pages in memory

SQLite Documentation

§Example

let pragma = Pragma::CacheSize(-2000);
assert_eq!(pragma.to_sql().sql(), "PRAGMA cache_size = -2000");
§

ForeignKeys(bool)

Query, set, or clear the enforcement of foreign key constraints

SQLite Documentation

§Example

let pragma = Pragma::ForeignKeys(true);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_keys = ON");

let pragma = Pragma::ForeignKeys(false);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_keys = OFF");
§

JournalMode(JournalMode)

Query or set the journal mode for databases

SQLite Documentation

§Example

let pragma = Pragma::JournalMode(JournalMode::Wal);
assert_eq!(pragma.to_sql().sql(), "PRAGMA journal_mode = WAL");
§

Synchronous(Synchronous)

Control how aggressively SQLite will write data

SQLite Documentation

§Example

let pragma = Pragma::Synchronous(Synchronous::Normal);
assert_eq!(pragma.to_sql().sql(), "PRAGMA synchronous = NORMAL");
§

TempStore(TempStore)

Query or set the storage mode used by temporary tables and indices

SQLite Documentation

§Example

let pragma = Pragma::TempStore(TempStore::Memory);
assert_eq!(pragma.to_sql().sql(), "PRAGMA temp_store = MEMORY");
§

LockingMode(LockingMode)

Query or set the database connection locking-mode

SQLite Documentation

§Example

let pragma = Pragma::LockingMode(LockingMode::Exclusive);
assert_eq!(pragma.to_sql().sql(), "PRAGMA locking_mode = EXCLUSIVE");
§

SecureDelete(SecureDelete)

Query or set the secure-delete setting

SQLite Documentation

§Example

let pragma = Pragma::SecureDelete(SecureDelete::Fast);
assert_eq!(pragma.to_sql().sql(), "PRAGMA secure_delete = FAST");
§

UserVersion(i32)

Set or get the user-version integer

SQLite Documentation

§Example

let pragma = Pragma::UserVersion(42);
assert_eq!(pragma.to_sql().sql(), "PRAGMA user_version = 42");
§

Encoding(Encoding)

Query or set the text encoding used by the database

SQLite Documentation

§Example

let pragma = Pragma::Encoding(Encoding::Utf8);
assert_eq!(pragma.to_sql().sql(), "PRAGMA encoding = UTF-8");
§

PageSize(i32)

Query or set the database page size in bytes

SQLite Documentation

§Example

let pragma = Pragma::PageSize(4096);
assert_eq!(pragma.to_sql().sql(), "PRAGMA page_size = 4096");
§

MmapSize(i64)

Query or set the maximum memory map size

SQLite Documentation

§Example

let pragma = Pragma::MmapSize(268435456);
assert_eq!(pragma.to_sql().sql(), "PRAGMA mmap_size = 268435456");
§

RecursiveTriggers(bool)

Enable or disable recursive trigger firing

SQLite Documentation

§Example

let pragma = Pragma::RecursiveTriggers(true);
assert_eq!(pragma.to_sql().sql(), "PRAGMA recursive_triggers = ON");
§

CollationList

Return a list of collating sequences

SQLite Documentation

§Example

let pragma = Pragma::CollationList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA collation_list");
§

CompileOptions

Return compile-time options used when building SQLite

SQLite Documentation

§Example

let pragma = Pragma::CompileOptions;
assert_eq!(pragma.to_sql().sql(), "PRAGMA compile_options");
§

DatabaseList

Return information about attached databases

SQLite Documentation

§Example

let pragma = Pragma::DatabaseList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA database_list");
§

FunctionList

Return a list of SQL functions

SQLite Documentation

§Example

let pragma = Pragma::FunctionList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA function_list");
§

TableList

Return information about tables and views in the schema

SQLite Documentation

§Example

let pragma = Pragma::TableList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_list");
§

TableXInfo(&'static str)

Return extended table information including hidden columns

SQLite Documentation

§Example

let pragma = Pragma::TableXInfo("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_xinfo(users)");
§

ModuleList

Return a list of available virtual table modules

SQLite Documentation

§Example

let pragma = Pragma::ModuleList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA module_list");
§

IntegrityCheck(Option<&'static str>)

Perform database integrity check

SQLite Documentation

§Example

// Check entire database
let pragma = Pragma::IntegrityCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA integrity_check");

// Check specific table
let pragma = Pragma::IntegrityCheck(Some("users"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA integrity_check(users)");
§

QuickCheck(Option<&'static str>)

Perform faster database integrity check

SQLite Documentation

§Example

let pragma = Pragma::QuickCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA quick_check");

let pragma = Pragma::QuickCheck(Some("users"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA quick_check(users)");
§

Optimize(Option<u32>)

Attempt to optimize the database

SQLite Documentation

§Example

let pragma = Pragma::Optimize(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA optimize");

let pragma = Pragma::Optimize(Some(0x10002));
assert_eq!(pragma.to_sql().sql(), "PRAGMA optimize(65538)");
§

ForeignKeyCheck(Option<&'static str>)

Check foreign key constraints for a table

SQLite Documentation

§Example

let pragma = Pragma::ForeignKeyCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_check");

let pragma = Pragma::ForeignKeyCheck(Some("orders"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_check(orders)");
§

TableInfo(&'static str)

Return information about table columns

SQLite Documentation

§Example

let pragma = Pragma::TableInfo("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_info(users)");
§

IndexList(&'static str)

Return information about table indexes

SQLite Documentation

§Example

let pragma = Pragma::IndexList("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA index_list(users)");
§

IndexInfo(&'static str)

Return information about index columns

SQLite Documentation

§Example

let pragma = Pragma::IndexInfo("idx_users_email");
assert_eq!(pragma.to_sql().sql(), "PRAGMA index_info(idx_users_email)");
§

ForeignKeyList(&'static str)

Return foreign key information for a table

SQLite Documentation

§Example

let pragma = Pragma::ForeignKeyList("orders");
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_list(orders)");

Implementations§

Source§

impl Pragma

Source

pub fn query(pragma_name: &str) -> SQL<'static, SQLiteValue<'static>>

Create a PRAGMA query to get the current value (read-only operation)

Source

pub fn foreign_keys(enabled: bool) -> Self

Convenience constructor for foreign_keys pragma

Source

pub fn journal_mode(mode: JournalMode) -> Self

Convenience constructor for journal_mode pragma

Source

pub fn table_info(table: &'static str) -> Self

Convenience constructor for table_info pragma

Source

pub fn index_list(table: &'static str) -> Self

Convenience constructor for index_list pragma

Source

pub fn foreign_key_list(table: &'static str) -> Self

Convenience constructor for foreign_key_list pragma

Source

pub fn integrity_check(table: Option<&'static str>) -> Self

Convenience constructor for integrity_check pragma

Source

pub fn foreign_key_check(table: Option<&'static str>) -> Self

Convenience constructor for foreign_key_check pragma

Source

pub fn table_xinfo(table: &'static str) -> Self

Convenience constructor for table_xinfo pragma

Source

pub fn encoding(encoding: Encoding) -> Self

Convenience constructor for encoding pragma

Trait Implementations§

Source§

impl Clone for Pragma

Source§

fn clone(&self) -> Pragma

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pragma

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Pragma

Source§

fn eq(&self, other: &Pragma) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> ToSQL<'a, SQLiteValue<'a>> for Pragma

Source§

fn to_sql(&self) -> SQLiteSQL<'a>

Source§

fn alias(&self, alias: &'static str) -> SQL<'a, V>

Source§

impl StructuralPartialEq for Pragma

Auto Trait Implementations§

§

impl Freeze for Pragma

§

impl RefUnwindSafe for Pragma

§

impl Send for Pragma

§

impl Sync for Pragma

§

impl Unpin for Pragma

§

impl UnwindSafe for Pragma

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<'a, V, L, R> SQLComparable<'a, V, R> for L
where V: SQLParam + 'a, L: ToSQL<'a, V>, R: ToSQL<'a, V>,