Name Description Size
backup.rs Online SQLite backup API. To create a [`Backup`], you must have two distinct [`Connection`]s - one for the source (which can be used while the backup is running) and one for the destination (which cannot). A [`Backup`] handle exposes three methods: [`step`](Backup::step) will attempt to back up a specified number of pages, [`progress`](Backup::progress) gets the current progress of the backup as of the last call to [`step`](Backup::step), and [`run_to_completion`](Backup::run_to_completion) will attempt to back up the entire source database, allowing you to specify how many pages are backed up at a time and how long the thread should sleep between chunks of pages. The following example is equivalent to "Example 2: Online Backup of a Running Database" from [SQLite's Online Backup API documentation](https://www.sqlite.org/backup.html). ```rust,no_run # use rusqlite::{backup, Connection, Result}; # use std::path::Path; # use std::time; fn backup_db<P: AsRef<Path>>( src: &Connection, dst: P, progress: fn(backup::Progress), ) -> Result<()> { let mut dst = Connection::open(dst)?; let backup = backup::Backup::new(src, &mut dst)?; backup.run_to_completion(5, time::Duration::from_millis(250), Some(progress)) } ``` 14391
blob
busy.rs Busy handler (when the database is locked) 6413
cache.rs Prepared statements cache for faster execution. 10273
collation.rs Add, remove, or modify a collation 6496
column.rs 8767
config.rs Configure database connections 6818
context.rs Code related to `sqlite3_context` common to `functions` and `vtab` modules. 2655
error.rs 18328
functions.rs Create or redefine SQL functions. # Example Adding a `regexp` function to a connection in which compiled regular expressions are cached in a `HashMap`. For an alternative implementation that uses SQLite's [Function Auxiliary Data](https://www.sqlite.org/c3ref/get_auxdata.html) interface to avoid recompiling regular expressions, see the unit tests for this module. ```rust use regex::Regex; use rusqlite::functions::FunctionFlags; use rusqlite::{Connection, Error, Result}; use std::sync::Arc; type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>; fn add_regexp_function(db: &Connection) -> Result<()> { db.create_scalar_function( "regexp", 2, FunctionFlags::SQLITE_UTF8 | FunctionFlags::SQLITE_DETERMINISTIC, move |ctx| { assert_eq!(ctx.len(), 2, "called with unexpected number of arguments"); let regexp: Arc<Regex> = ctx.get_or_create_aux(0, |vr| -> Result<_, BoxError> { Ok(Regex::new(vr.as_str()?)?) })?; let is_match = { let text = ctx .get_raw(1) .as_str() .map_err(|e| Error::UserFunctionError(e.into()))?; regexp.is_match(text) }; Ok(is_match) }, ) } fn main() -> Result<()> { let db = Connection::open_in_memory()?; add_regexp_function(&db)?; let is_match: bool = db.query_row("SELECT regexp('[aeiou]*', 'aaaaeeeiii')", [], |row| { row.get(0) })?; assert!(is_match); Ok(()) } ``` 34570
hooks.rs Commit, Data Change and Rollback Notification Callbacks 26085
inner_connection.rs 16392
lib.rs Rusqlite is an ergonomic wrapper for using SQLite from Rust. Historically, the API was based on the one from [`rust-postgres`](https://github.com/sfackler/rust-postgres). However, the two have diverged in many ways, and no compatibility between the two is intended. ```rust use rusqlite::{params, Connection, Result}; #[derive(Debug)] struct Person { id: i32, name: String, data: Option<Vec<u8>>, } fn main() -> Result<()> { let conn = Connection::open_in_memory()?; conn.execute( "CREATE TABLE person ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, data BLOB )", (), // empty list of parameters. )?; let me = Person { id: 0, name: "Steven".to_string(), data: None, }; conn.execute( "INSERT INTO person (name, data) VALUES (?1, ?2)", (&me.name, &me.data), )?; let mut stmt = conn.prepare("SELECT id, name, data FROM person")?; let person_iter = stmt.query_map([], |row| { Ok(Person { id: row.get(0)?, name: row.get(1)?, data: row.get(2)?, }) })?; for person in person_iter { println!("Found person {:?}", person.unwrap()); } Ok(()) } ``` 74437
limits.rs Run-Time Limits 6334
load_extension_guard.rs 1343
params.rs 17659
pragma.rs Pragma helpers 13219
raw_statement.rs 7009
row.rs 17988
serialize.rs Serialize a database. 4743
session.rs [Session Extension](https://sqlite.org/sessionintro.html) 28490
statement.rs 46401
trace.rs Tracing and profiling functions. Error and warning log. 6342
transaction.rs 24627
types
unlock_notify.rs [Unlock Notification](http://sqlite.org/unlock_notify.html) 3998
util
version.rs 758
vtab