sqlx
SQLx is an async Rust SQL toolkit that enables compile-time checked database queries without a DSL. It supports PostgreSQL, MySQL, MariaDB, and SQLite with pure Rust drivers (except SQLite, which wraps libsqlite3) and is runtime/TLS agnostic.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | transact-rs/sqlx |
| Owner | transact-rs |
| Primary language | Rust |
| License | Apache-2.0 — OSI-approved |
| Stars | 17.3k |
| Forks | 1.6k |
| Open issues | 749 |
| Latest release | Unknown |
| Last updated | 2026-07-07 |
| Source | https://github.com/transact-rs/sqlx |
What sqlx is
A zero-unsafe async SQL client for Rust (forbid(unsafe_code) except sqlite feature) featuring compile-time query validation via macros, connection pooling, row streaming, statement caching, and support for multiple async runtimes (tokio, async-std, actix) and TLS backends (native-tls, rustls). MySQL/PostgreSQL drivers are pure Rust; SQLite uses libsqlite3-sys bindings.
Get the sqlx source
Clone the repository and explore it locally.
git clone https://github.com/transact-rs/sqlx.gitcd sqlx# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Compile-time query checking requires the macros feature and a live database connection during compilation; CI/CD must provide database access or use offline mode.
- Runtime and TLS backend must be selected explicitly via Cargo features; mismatched runtime (e.g., tokio queries in async-std) will cause panics.
- Connection pooling (sqlx::Pool) is built-in but requires explicit configuration; tune pool size, timeout, and idle behavior for your workload.
- SQLite with compile-time checks requires static linking or system SQLite 3.20.0+; bundled mode simplifies but increases binary size.
- Transaction handling uses savepoints for nesting; ensure your application handles rollback semantics correctly, especially in error paths.
When to avoid it — and what to weigh
- MSSQL is required — MSSQL support was removed after version 0.7 and is pending a full rewrite; production MSSQL users must stay on 0.6.x or migrate to alternatives.
- ORM-like features are essential — SQLx is explicitly not an ORM; it lacks automatic relationship mapping, query builders, or schema generation. If you need those, consider Diesel or sqlc.
- Zero compile-time overhead is required — Compile-time checked queries (query! macro) require database connectivity at compile time; if offline builds are mandatory, disable macros and use runtime-only mode.
- Non-Rust environments — SQLx is Rust-only; no official language bindings or language-agnostic wrapper libraries are provided in the core project.
License & commercial use
Licensed under Apache License 2.0 (Apache-2.0), a permissive OSI-approved license.
Apache-2.0 is a permissive license that permits commercial use, modification, and distribution under clear terms (provide notice of changes, include license copy, state modifications). No license fee or contributor agreement required. Verify compliance with all transitive dependencies' licenses.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Moderate |
| DEV.co fit | Strong |
| Assessment confidence | High |
Postgres and MySQL/MariaDB drivers use #![forbid(unsafe_code)] (zero-unsafe except SQLite), reducing memory-safety risks. SQLite driver uses libsqlite3-sys with unsafe bindings; ensure system or bundled SQLite is kept current. Supports TLS (native-tls and rustls variants) for transport security. No details on SQL injection mitigation beyond parameterized queries (query! macro enforces static SQL, reducing injection surface). No independent security audit data provided; requires review of your threat model.
Alternatives to consider
Diesel
Mature Rust ORM with schema generation, relationship mapping, and query builder; better if you need abstraction beyond raw SQL, but less flexible for dynamic queries.
sqlc (or upstream sqlc-gen-go et al.)
SQL-first code generation for type safety across languages; simpler if polyglot stacks or offline code generation is preferred, but no async runtime integration.
SeaORM
Async-first Rust ORM with similar runtime flexibility; choose if you prioritize ORM convenience over SQLx's minimal-abstraction philosophy.
Build on sqlx with DEV.co software developers
SQLx brings compile-time safety and async-first performance to Rust backends. Let Devco help you architect a scalable, maintainable database integration for your microservices or API.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
sqlx FAQ
Can I use SQLx without compile-time query checking?
Does SQLx work with async-std AND tokio in the same binary?
Is MSSQL supported?
How does compile-time checking work offline (in CI without a database)?
Work with a software development agency
Adopting sqlx is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source databases software in production.
Ready to Build a Type-Safe Database Layer?
SQLx brings compile-time safety and async-first performance to Rust backends. Let Devco help you architect a scalable, maintainable database integration for your microservices or API.