SQLx
Async, pure-Rust SQL toolkit with compile-time checked queries and no DSL
Repository Health
Technical Analysis
SQLx is an async, pure-Rust SQL crate that verifies your queries against a real development database at compile time — without imposing a query-builder DSL on top of SQL. You write plain SQL strings inside query!/query_as! macros, and SQLx connects to your dev database during the build to confirm the query is valid and infer the returned row’s shape.
It ships native, mostly-unsafe-free drivers for PostgreSQL, MySQL/MariaDB, and SQLite, is runtime-agnostic (works with tokio or async-std) and TLS-agnostic (native-tls or rustls), and adds connection pooling, row streaming, LISTEN/NOTIFY support, nested transactions with savepoints, and an offline mode for compiling without a live database connection.
What You Get
- Compile-time checked
query!/query_as!macros that validate SQL against your dev database and infer Rust types for returned rows - Native async drivers for PostgreSQL, MySQL/MariaDB, and SQLite (SQLite links libsqlite3 since it’s not a network database)
- Runtime-agnostic support for tokio and async-std, with native-tls or rustls TLS backends
- Built-in connection pooling (
sqlx::Pool), row streaming, and anAnydriver for choosing the backend at runtime via URL scheme - Offline mode (
sqlx-cli) soquery!macros can compile in CI without a live database connection - Compile-time embedded migrations via the
migrate!macro
Common Use Cases
- Backend services that want SQL-level control (window functions, CTEs, extension-specific syntax) with compile-time safety instead of an ORM’s abstraction
- Rust web APIs (Axum, Actix) needing a connection pool plus typed row mapping without hand-rolled
FromRowboilerplate - Projects that need to target multiple databases (Postgres in prod, SQLite in tests) through the
Anydriver - CI pipelines that need query-macro compile-time checks without provisioning a live database, via offline mode
Under The Hood
Architecture - SQLx is a Cargo workspace split into sqlx-core (the shared connection/pool/row abstractions and Executor/Connection traits), per-database driver crates (sqlx-postgres, sqlx-mysql, sqlx-sqlite) that implement those traits against each wire protocol, sqlx-macros/sqlx-macros-core (the proc-macro layer that talks to a dev database or offline query cache at compile time to type-check query!), and sqlx-cli for migrations and offline-mode cache generation; the top-level sqlx crate just re-exports the pieces selected by Cargo features. Tech Stack - pure Rust throughout except SQLite (which links the C libsqlite3 library via libsqlite3-sys, the one place unsafe is required); async execution is runtime-agnostic (tokio or async-std) and TLS is pluggable (native-tls or rustls), selected entirely through Cargo feature flags. Code Quality - the workspace carries an extensive tests/ directory per driver plus sqlx-test helpers, a clippy.toml enforcing lint conventions, and #![forbid(unsafe_code)] on non-SQLite builds, giving strong guarantees around one of Rust’s largest and most feature-flag-heavy crates; the sheer number of driver/runtime/TLS feature combinations does make the build matrix and CI surface large to reason about. API Design - the query!/query_as! macros give an unusually low-boilerplate path from a SQL string to a typed Rust value without a query-builder DSL to learn, though the tradeoff is that the compile-time-checking feature requires a live dev database (or a maintained offline cache file) in the build environment, which is an extra piece of infrastructure most ORMs don’t require.
Used by 14 apps in this directory
cocoindex
Data Engineering · AI Development
An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.
Hook0
Devops
Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.
Jan
AI Assistants
Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.
Laminar
AI Development · Monitoring
Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.
Manticore Search
Search
An open-source, C++ search database positioned as a faster, lighter alternative to Elasticsearch — supporting full-text, SQL, JSON, and vector/embedding search over a MySQL-compatible protocol.
Meetily
Productivity · AI Assistants
Privacy-first AI meeting assistant that transcribes and summarizes your meetings entirely on your local machine — no cloud, no data leakage.
OpenViking
Databases · AI Development
An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.
ParadeDB
Search · Databases · Analytics
Born out of Y Combinator's S2023 batch, ParadeDB is a Postgres extension that delivers Elasticsearch-quality BM25 search and real-time analytics without a separate search cluster to manage.
PostgresML
Databases · AI Development
Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.