Build a Rust web API that reads and writes to PostgreSQL with queries verified correct at compile time.
Add an async connection pool to a Tokio-based Rust service with streaming query results.
Stream large result sets row-by-row from SQLite without loading everything into memory at once.
Receive real-time events from PostgreSQL using async LISTEN and NOTIFY in a Rust background service.
Compile-time checked queries require a running development database at build time and DATABASE_URL set in the environment.
SQLx is a Rust library for talking to SQL databases, the ones that store data in tables, like PostgreSQL, MySQL, MariaDB and SQLite. It is meant for Rust programmers who want to write actual SQL queries rather than going through a heavy abstraction that hides the database. The project calls itself the Rust SQL toolkit. Its standout feature is compile-time checked queries. You hand SQLx a SQL statement and, while your code is being compiled, it actually contacts your development database, verifies the query is valid, and confirms that the types of the results match what your Rust code expects. If the query is wrong or the schema has changed, the build fails before the program runs. This is optional, you can also issue queries the normal way without the check. SQLx is built to be asynchronous, meaning many database operations can be in flight at once without blocking. It works with the popular Rust async runtimes (async-std, tokio, actix) and TLS backends (native-tls, rustls). It ships with a built-in connection pool, streams rows as they arrive, caches prepared statements, supports nested transactions with save points, and offers PostgreSQL-specific features like asynchronous LISTEN and NOTIFY notifications. An Any driver lets you pick the database at runtime from the connection URL. The Postgres and MySQL/MariaDB drivers are pure Rust with no unsafe code, the SQLite driver wraps the libsqlite3 C library because SQLite is embedded. Reach for SQLx when building a Rust application that needs a real database, you want first-class async support, and you would rather write SQL directly, with the safety net of compile-time verification, than adopt a full ORM.
← launchbadge on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.