SQLX
lastmod 2025-08-04created 2025-08-042 edits
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite.
Open-source Rust-based SQL toolkit
About
- An asynchronous (async), pure Rust SQL Crate that uses Rust macros to validate SQL queries at compile time without a DSL
- Not an ORM! : Ideal for projects that want to use SQL as-is without an ORM
- Easy compile-time checks by specifying DATABASE_URL in a .env file
Features
- Connection pooling with sqlx::Pool
- Asynchronous Row streaming of data from the database
- Automatic per-connection query preparation and caching
- Unprepared (non-Prepared) queries can also be run easily, with results returned as the same Row type
- TLS encrypted connections on supported DBs (MySQL, MariaDB, PostgreSQL)
- Asynchronous PostgreSQL notification support : LISTEN and NOTIFY
- Nested transaction support using Savepoints
- AnyPool support for selectively swapping the DB driver at runtime