SQLx is the Rust SQL toolkit that checks your queries at compile time — without forcing you to use a domain-specific language. Write plain SQL for PostgreSQL, MySQL, MariaDB, or SQLite, and SQLx will verify your queries against a real database before your code ever ships.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.
Quickstart
Connect to a database and run your first query in minutes
Installation
Add SQLx to your Cargo.toml with the right features
Compile-time Queries
Learn how the query! macro checks SQL at compile time
API Reference
Explore the full SQLx public API surface
Why SQLx?
SQLx is not an ORM. It gives you full control of your SQL while eliminating an entire class of runtime errors through compile-time verification.Truly Async
Built from the ground up with async/await. Works with Tokio, async-std, and actix runtimes.
Compile-time Safety
The
query! macro connects to your dev database at build time to verify SQL correctness and types.Pure Rust Drivers
PostgreSQL and MySQL drivers are written in pure Rust with zero unsafe code.
Multi-database
First-class support for PostgreSQL, MySQL, MariaDB, and SQLite with a shared API.
Get started
Add SQLx to your project
Add SQLx to your
Cargo.toml with your chosen runtime and database features:Cargo.toml
Explore by topic
Connection Pool
Manage database connections efficiently with built-in pooling
Migrations
Create and manage database schema migrations
Database Drivers
Database-specific features for PostgreSQL, MySQL, and SQLite
Type System
Map SQL types to Rust types, including custom types
SQLx CLI
Command-line tool for database management and offline mode
Offline Mode
Build without a database connection using cached query metadata