SQLx

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
73 /100 Good
Development Activity 80
Maintenance 44
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 85
Code Quality 82
Innovation 84
Learning Curve 68

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 17 apps in this directory

Rust
52%
Apache 2.0

cocoindex

AI Development · Data Engineering

11,607

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

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 52%
Python 48%
Updated 4 days ago
Rust
37%
Other

Hook0

Devops

1,491

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
82
Repo Health
82
Technical
69
Dependency
Built with
Rust 37%
TypeScript 12%
Updated 1 weeks ago
Rust
52%
Other

Jan

AI Assistants

44,680

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
65
Dependency
Built with
Rust 52%
TypeScript 44%
Updated 4 days ago
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,285

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
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated 5 days ago
C++
77%
GPL 3.0

Manticore Search

Search

12,038

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
77
Dependency
Built with
C++ 77%
Updated 5 days ago
Rust
48%
MIT

Meetily

AI Assistants · Productivity

31,171

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

View details
85
Repo Health
72
Technical
67
Dependency
Built with
Rust 48%
TypeScript 29%
Updated 2 weeks ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

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

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 4 days ago
Rust
86%
AGPL 3.0

ParadeDB

Analytics · Databases · Search

9,311

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
89
Repo Health
87
Technical
68
Dependency
Built with
Rust 86%
PLpgSQL 14%
Updated 4 days ago
Rust
63%
MIT

PostgresML

AI Development · Databases

6,825

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

View details
51
Repo Health
76
Technical
64
Dependency
Built with
Rust 63%
JavaScript 11%
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