Use this file to discover all available pages before exploring further.
SQLx uses Cargo feature flags to configure which async runtime, TLS backend, and database drivers are compiled in. You must choose at least one runtime feature. TLS and database features are optional but almost always needed in practice.
Pick the combination of runtime and TLS that matches your project. The examples below use PostgreSQL; substitute mysql or sqlite as needed.
[dependencies]sqlx = { version = "0.8", features = ["runtime-tokio", "tls-native-tls", "postgres", "macros"] }tokio = { version = "1", features = ["full"] }
You must select exactly one runtime feature. Combining multiple runtime features in the same dependency is not supported and will produce a compile error.
Uses OpenSSL on Linux, SChannel on Windows, Secure Transport on macOS. Broadest compatibility with older TLS versions.
tls-rustls-ring-webpki
rustls with ring + WebPKI CA roots
Cross-platform pure Rust TLS. Uses WebPKI certificate roots bundled with the binary. Supports TLS 1.2 and 1.3 only.
tls-rustls-ring-native-roots
rustls with ring + system CA roots
Same as above but reads CA certificates from the operating system’s trust store.
tls-rustls-aws-lc-rs
rustls with aws-lc-rs
Uses AWS’s fork of BoringSSL as the cryptographic backend instead of ring.
rustls only supports TLS 1.2 and 1.3. If your database server only supports older TLS versions, use tls-native-tls instead. Connections to such servers with a rustls backend will fail with a HandshakeFailure or CorruptMessage error.
Adds support for the PostgreSQL database. Pure Rust driver.
mysql
Adds support for MySQL and MariaDB. Pure Rust driver.
mysql-rsa
Enables RSA password encryption for caching_sha2_password / sha256_password auth when TLS is not used. Only enable this if you must connect without TLS to servers that require RSA auth. Prefer using TLS instead.
sqlite
Adds support for SQLite using a bundled, statically linked libsqlite3. Enables sqlite-bundled, sqlite-deserialize, sqlite-load-extension, and sqlite-unlock-notify.
sqlite-unbundled
Same as sqlite, but links SQLite from the system instead of the bundled version. Allows updating SQLite independently of SQLx or using a forked build. Requires SQLite 3.20.0 or newer on the system. May increase build time due to bindgen.
any
Adds the Any database driver, which selects a concrete driver at runtime based on the URL scheme. Useful for applications that need to support multiple databases from a single binary.
These features apply only when sqlite or sqlite-unbundled is also enabled.
Feature
Description
sqlite-bundled
Bundle and statically link SQLite. Included by the sqlite shorthand feature.
sqlite-deserialize
Enables SqliteConnection::deserialize() and ::serialize(). Cannot be used with -DSQLITE_OMIT_DESERIALIZE. Requires -DSQLITE_ENABLE_DESERIALIZE on SQLite versions older than 3.36.0.
sqlite-load-extension
Enables SqliteConnectOptions::extension() and ::extension_with_entrypoint(). Required to use drivers.sqlite.unsafe-load-extensions from sqlx.toml. Cannot be used with -DSQLITE_OMIT_LOAD_EXTENSION.
sqlite-preupdate-hook
Enables the sqlite3_preupdate_hook API. Requires -DSQLITE_ENABLE_PREUPDATE_HOOK, which is set automatically when using sqlite-bundled. Using this with sqlite-unbundled may cause linker failures if the system SQLite does not support it.
sqlite-unlock-notify
Enables internal handling of SQLITE_LOCKED_SHAREDCACHE. Requires -DSQLITE_ENABLE_UNLOCK_NOTIFY, which is set automatically when using sqlite-bundled.
chrono and time cover overlapping SQL types. If both are enabled, query! will prefer chrono. Enabling both is generally not recommended unless you are migrating between them.
The query! macro does significant work at compile time. You can reduce incremental build times by compiling sqlx-macros with optimizations in your development profile:
Cargo.toml
[profile.dev.package.sqlx-macros]opt-level = 3
This setting applies only to the sqlx-macros crate and does not affect your own code’s debug information or compile-time error quality.
If you need to build without a live database (for example, in CI), you can use offline mode. Run cargo sqlx prepare to cache query metadata into a .sqlx directory, then set SQLX_OFFLINE=true at build time to use the cached data instead of connecting to the database.Offline mode is always available — it does not require a separate feature flag. See the sqlx-cli README for setup instructions.