Documentation Index
Fetch the complete documentation index at: https://mintlify.com/launchbadge/sqlx/llms.txt
Use this file to discover all available pages before exploring further.
SQLx is a highly modular crate. Almost all functionality — including the async runtime, TLS backend, database drivers, and Rust type integrations — is gated behind Cargo feature flags. You must enable at least one runtime feature and one database feature to compile a working SQLx integration.
The default feature set is any, macros, migrate, and json. In most cases you will want to replace this with an explicit list tailored to your project.
[dependencies]
sqlx = { version = "0.8", default-features = false, features = [
"runtime-tokio",
"tls-rustls-ring-webpki",
"postgres",
"macros",
"migrate",
"uuid",
"chrono",
] }
Runtime features
Exactly one runtime feature must be enabled. These features are not TLS-coupled — pair them with a TLS feature separately.
| Feature | Async runtime |
|---|
runtime-tokio | Tokio |
runtime-async-std | async-std |
runtime-async-global-executor | async-global-executor |
runtime-smol | smol |
TLS features
TLS is required by most hosted databases over public networks. Choose one TLS backend, or use tls-none to compile without TLS support (useful for local development or when the connection is secured at the network layer).
| Feature | Backend |
|---|
tls-rustls-ring-webpki | rustls with the Ring crypto provider and WebPKI roots |
tls-rustls-ring-native-roots | rustls with Ring and native system certificate roots |
tls-rustls-aws-lc-rs | rustls with the AWS-LC-rs crypto provider |
tls-native-tls | Platform-native TLS (openssl on Linux, Secure Transport on macOS, SChannel on Windows) |
tls-none | No TLS support (compile-time no-op flag) |
tls-rustls-ring and tls-rustls are kept as aliases for backward compatibility. They resolve to tls-rustls-ring-webpki. Prefer the explicit names in new projects.
Database features
Enable exactly the drivers you need.
| Feature | Driver |
|---|
postgres | PostgreSQL and compatible databases |
mysql | MySQL and MariaDB |
mysql-rsa | Adds RSA-encrypted password support for MySQL (sha2_password / caching_sha2_password) |
sqlite | SQLite via bundled libsqlite3. Enables sqlite-bundled, sqlite-deserialize, sqlite-load-extension, and sqlite-unlock-notify |
sqlite-bundled | SQLite with a bundled copy of libsqlite3 (requires a C compiler) |
sqlite-unbundled | SQLite linking against the system-provided libsqlite3 |
any | Type-erased AnyPool / AnyConnection that dispatches to any enabled driver at runtime |
SQLite sub-features
These features expose conditionally compiled SQLite APIs. They require sqlite-bundled or sqlite-unbundled to also be enabled, and some require specific compile-time flags on the underlying C library.
| Feature | Description |
|---|
sqlite-deserialize | Enables SqliteConnection::deserialize() and ::serialize(). Incompatible with -DSQLITE_OMIT_DESERIALIZE; requires -DSQLITE_ENABLE_DESERIALIZE on SQLite < 3.36.0. |
sqlite-load-extension | Enables SqliteConnectOptions::extension() and ::extension_with_entrypoint(). Also required to use drivers.sqlite.unsafe-load-extensions in sqlx.toml. Incompatible with -DSQLITE_OMIT_LOAD_EXTENSION. |
sqlite-preupdate-hook | Enables sqlite3_preupdate_hook. Requires -DSQLITE_ENABLE_PREUPDATE_HOOK (set automatically by sqlite-bundled). |
sqlite-unlock-notify | Enables internal handling of SQLITE_LOCKED_SHAREDCACHE. Requires -DSQLITE_ENABLE_UNLOCK_NOTIFY (set automatically by sqlite-bundled). |
Macro and utility features
| Feature | Description |
|---|
macros | Enables the query!, query_as!, query_scalar!, and query_file! compile-time macro family. Enables derive and offline mode. |
derive | Enables #[derive(FromRow)] and #[derive(Type)]. |
migrate | Enables sqlx::migrate!() and the migration runner. |
sqlx-toml | Enables parsing of a sqlx.toml configuration file in the crate root. Not enabled by default. See the sqlx.toml configuration reference. |
Type features
These features add support for mapping database types to popular Rust crates. Each feature enables integration across all drivers that support the corresponding SQL type.
| Feature | Rust crate | SQL types |
|---|
json | serde_json::Value | JSON, JSONB |
uuid | uuid | UUID |
chrono | chrono | DATE, TIME, DATETIME, TIMESTAMP |
time | time | DATE, TIME, DATETIME, TIMESTAMP |
bigdecimal | bigdecimal | NUMERIC, DECIMAL |
rust_decimal | rust_decimal | NUMERIC, DECIMAL |
ipnet | ipnet | CIDR, INET (Postgres) |
ipnetwork | ipnetwork | CIDR, INET (Postgres) |
mac_address | mac_address | MACADDR (Postgres) |
bit-vec | bit-vec | BIT, VARBIT (Postgres) |
bstr | bstr | Binary string types |
When both chrono and time are enabled (for example via Cargo feature unification), time takes precedence. Similarly, when both bigdecimal and rust_decimal are enabled, rust_decimal takes precedence. Use sqlx.toml with the sqlx-toml feature to override this behavior — see macros.preferred-crates.