quex_driver/lib.rs
1//! Low-level async database drivers used by `quex`.
2//!
3//! This crate exposes driver-specific building blocks for mariadb, mysql,
4//! postgres, and sqlite. Most applications should start with the `quex` crate,
5//! which wraps these APIs behind one facade. Use `quex-driver` directly when you
6//! need driver-specific control or want to avoid the facade layer.
7//!
8//! The mysql and postgres drivers use the native client libraries through ffi:
9//! libmariadb for mysql/mariadb and libpq for postgres. The sqlite driver uses
10//! sqlite3 from a worker thread.
11//!
12//! Add it directly only when you want the lower-level driver api:
13//!
14//! ```toml
15//! quex-driver = "0.1"
16//! ```
17//!
18//! Backend support is feature-gated. Enable only the modules you need:
19//!
20//! - `mysql` for mysql and mariadb
21//! - `postgres` for postgres
22//! - `sqlite` for sqlite
23//!
24//! No backend is enabled by default.
25//!
26//! Each enabled module exposes its own connect options, connection type, row
27//! types, statement types, and values. The types are intentionally
28//! driver-specific; if you want one shared api across all three backends, use
29//! `quex`.
30//!
31//! ```no_run
32//! # #[cfg(feature = "mariadb")]
33//! # async fn run() -> quex_driver::mysql::Result<()> {
34//! let mut conn = quex_driver::mysql::Connection::connect(
35//! quex_driver::mysql::ConnectOptions::new()
36//! .host("127.0.0.1")
37//! .user("root")
38//! .database("app"),
39//! )
40//! .await?;
41//!
42//! let mut rows = conn.query("select 1").await?;
43//! while let Some(row) = rows.next().await? {
44//! let value = row.get_i64(0)?;
45//! }
46//! # Ok(())
47//! # }
48//! ```
49
50#![cfg_attr(not(unix), allow(unused))]
51
52#[cfg(not(unix))]
53compile_error!("quex-driver currently supports Unix-like platforms only");
54
55#[cfg(feature = "mariadb")]
56pub mod mysql;
57#[cfg(feature = "postgres")]
58pub mod postgres;
59#[cfg(feature = "sqlite")]
60pub mod sqlite;