async_sqlite/
lib.rs

1//! # async-sqlite
2//!
3//! A library to interact with sqlite from an async context.
4//!
5//! This library is tested on both [tokio](https://docs.rs/tokio/latest/tokio/)
6//! and [async_std](https://docs.rs/async-std/latest/async_std/), however
7//! it should be compatible with all async runtimes.
8//!
9//! ## Usage
10//!
11//! A `Client` represents a single background sqlite3 connection that can be called
12//! concurrently from any thread in your program.
13//!
14//! To create a sqlite client and run a query:
15//!
16//! ```rust
17//! use async_sqlite::{ClientBuilder, JournalMode};
18//!
19//! # async fn run() -> Result<(), async_sqlite::Error> {
20//! let client = ClientBuilder::new()
21//!                 .path("/path/to/db.sqlite3")
22//!                 .journal_mode(JournalMode::Wal)
23//!                 .open()
24//!                 .await?;
25//!
26//! let value: String = client.conn(|conn| {
27//!     conn.query_row("SELECT val FROM testing WHERE id=?", [1], |row| row.get(0))
28//! }).await?;
29//!
30//! println!("Value is: {value}");
31//! # Ok(())
32//! }
33//! ```
34//!
35//! A `Pool` represents a collection of background sqlite3 connections that can be
36//! called concurrently from any thread in your program.
37//!
38//! To create a sqlite pool and run a query:
39//!
40//! ```rust
41//! use async_sqlite::{JournalMode, PoolBuilder};
42//!
43//! # async fn run() -> Result<(), async_sqlite::Error> {
44//! let pool = PoolBuilder::new()
45//!               .path("/path/to/db.sqlite3")
46//!               .journal_mode(JournalMode::Wal)
47//!               .open()
48//!               .await?;
49//!
50//! let value: String = pool.conn(|conn| {
51//!     conn.query_row("SELECT val FROM testing WHERE id=?", [1], |row| row.get(0))
52//! }).await?;
53//!
54//! println!("Value is: {value}");
55//! # Ok(())
56//! # }
57//! ```
58//!
59//! ## Cargo Features
60//!
61//! This library tries to export almost all features that the underlying
62//! [rusqlite](https://docs.rs/rusqlite/latest/rusqlite/) library contains.
63//!
64//! A notable difference is that the `bundled` feature is **enabled** by default,
65//! but can be disabled with the following line in your Cargo.toml:
66//!
67//! ```toml
68//! async-sqlite = { version = "*", default-features = false }
69//! ```
70
71pub use rusqlite;
72
73mod client;
74mod error;
75mod pool;
76
77pub use client::{Client, ClientBuilder, JournalMode};
78pub use error::Error;
79pub use pool::{Pool, PoolBuilder};