SQLx

Async, pure-Rust SQL toolkit with compile-time checked queries and no DSL

Library
Cargo
v0.9.0
17,397stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
70/100Good
Development Activity80
Maintenance32
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture85
Code Quality82
Innovation84
Learning Curve68

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 an Any driver for choosing the backend at runtime via URL scheme
  • Offline mode (sqlx-cli) so query! 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 FromRow boilerplate
  • Projects that need to target multiple databases (Postgres in prod, SQLite in tests) through the Any driver
  • 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

Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,350

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated yesterday
Rust
41%
Other

Hook0

Devops

1,477

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.

View details
83
Repo Health
82
Technical
70
Dependency
Built with
Rust41%
TypeScript17%
JavaScript15%
Updated today
TypeScript
75%
Other

Jan

AI Assistants

44,052

Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.

View details
90
Repo Health
81
Technical
66
Dependency
Built with
TypeScript75%
Rust21%
Updated today
TypeScript
69%
Apache 2.0

Laminar

AI Development · Monitoring

3,180

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
70
Dependency
Built with
TypeScript69%
Rust29%
Updated yesterday
C++
77%
GPL 3.0

Manticore Search

Search

11,948

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.

View details
91
Repo Health
70
Technical
78
Dependency
Built with
C++77%
Updated today
Rust
46%
MIT

Meetily

Productivity · AI Assistants

29,484

Privacy-first AI meeting assistant that transcribes and summarizes your meetings entirely on your local machine — no cloud, no data leakage.

View details
70
Repo Health
72
Technical
71
Dependency
Built with
Rust46%
TypeScript30%
Updated 2 months ago
Python
74%
AGPL 3.0

OpenViking

Databases · AI Development

29,711

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
84
Repo Health
75
Technical
65
Dependency
Built with
Python74%
Rust14%
Updated today
Rust
87%
AGPL 3.0

ParadeDB

Search · Databases · Analytics

9,175

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.

View details
88
Repo Health
87
Technical
71
Dependency
Built with
Rust87%
PLpgSQL12%
Updated today
Rust
63%
MIT

PostgresML

Databases · AI Development

6,817

Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.

View details
51
Repo Health
76
Technical
65
Dependency
Built with
Rust63%
JavaScript11%
Updated 1 years ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search