launchbadge / sqlx
đź§° The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite.
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing launchbadge/sqlx in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewSQLx 🧰 The Rust SQL Toolkit Install | Usage | Docs | Ecosystem | Discord Built with ❤️ by The LaunchBadge team Have a question? Be sure to check the FAQ first! SQLx is an async, pure Rust †SQL crate featuring compile-time checked queries without a DSL. • **Truly Asynchronous**. Built from the ground-up using async/await for maximum concurrency. • **Compile-time checked queries** (if you want). See SQLx is not an ORM. • **Database Agnostic**. Support for [PostgreSQL], [MySQL], [MariaDB], [SQLite]. • [MSSQL] was supported prior to version 0.7, but has been removed pending a full rewrite of the driver as part of our [SQLx Pro initiative]. • **Pure Rust**. The Postgres and MySQL/MariaDB drivers are written in pure Rust using **zero** unsafe ††code. • **Runtime Agnostic**. Works on different runtimes ([ ] / [ ] / [ ]) and TLS backends ([ ], [ ]). †The SQLite driver uses the libsqlite3 C library as SQLite is an embedded database (the only way we could be pure Rust for SQLite is by porting _all_ of SQLite to Rust). ††SQLx uses unless the feature is enabled. The SQLite driver directly invokes the SQLite3 API via , which requires . [postgresql]: http://postgresql.org/ [sqlite]: https://sqlite.org/ [mysql]: https://www.mysql.com/ [mariadb]: https://www.mariadb.org/ [mssql]: https://www.microsoft.com/en-us/sql-server [SQLx Pro initiative]: https://github.com/launchbadge/sqlx/discussions/1616 --- • Cross-platform. Being native Rust, SQLx will compile anywhere Rust is supported. • Built-in connection pooling with . • Row streaming. Data is read asynchronously from the database and decoded on demand. • Automatic statement preparation and caching. When using the high-level query API ( ), statements are prepared and cached per connection. • Simple (unprepared) query execution including fetching results into the same types used by the high-level API. Supports batch execution and returns results from all statements. • Transport Layer Security (TLS) where supported ([MySQL], [MariaDB] and [PostgreSQL]). • Asynchronous notifications using and for [PostgreSQL]. • Nested transactions with support for save points. • database driver for changing the database driver at runtime. An connects to the driver indicated by the URL scheme. Install SQLx is compatible with the [ ], [ ], and [ ] runtimes; and, the [ ] and [ ] TLS backends. When adding the dependency, you must choose a runtime feature that is + . [ ]: https://github.com/async-rs/async-std [ ]: https://github.com/tokio-rs/tokio [ ]: https://github.com/actix/actix-net [ ]: https://crates.io/crates/native-tls [ ]: https://crates.io/crates/rustls Cargo Feature Flags For backward-compatibility reasons, the runtime and TLS features can either be chosen together as a single feature, or separately. For forward compatibility, you should use the separate runtime and TLS features as the combination features may be removed in the future. • : Use the runtime without enabling a TLS backend. • : Use the runtime without enabling a TLS backend. • Actix-web is fully compatible with Tokio and so a separate runtime feature is no longer needed. • : Use the TLS backend (OpenSSL on *nix, SChannel on Windows, Secure Transport on macOS). • : Use the TLS backend (cross-platform backend, only supports TLS 1.2 and 1.3). • : Add support for the Postgres database server. • : Add support for the MySQL/MariaDB database server. • : Add support for the MSSQL database server. • : Add support for the self-contained SQLite database engine with SQLite bundled and statically-linked. • : The same as above ( ), but link SQLite from the system instead of the bundled version. • Allows updating SQLite independently of SQLx or using forked versions. • You must have SQLite installed on the system or provide a path to the library at build time. See the README for details. • May result in link errors if the SQLite version is too old. Version or newer is recommended. • Can increase build time due to the use of bindgen. • : enables SQLite's preupdate hook API. • Exposed as a separate feature because it's generally not enabled by default. • Using this feature with may cause linker failures if the system SQLite version does not support it. • : Add support for the database driver, which can proxy to a database driver at runtime. • : Add support for the derive family macros, those are , , , . • : Add support for the macros, which allows compile-time checked queries. • : Add support for the migration management and macro, which allow compile-time embedded migrations. • : Add support for UUID. • : Add support for date and time types from . • : Add support for date and time types from crate (alternative to , which is preferred by macro, if both enabled) • : Add support for . • : Add support for using the crate. • : Add support for using the crate. • : Add support for and (in postgres) using the crate. • : Add support for and (in postgres) using the crate. • : Add support for and (in postgres) using the crate. • Offline mode is now always enabled. See [sqlx-cli/README.md][readme-offline]. [readme-offline]: sqlx-cli/README.md#enable-building-in-offline-mode-with-query SQLx is not an ORM! SQLx supports **compile-time checked queries**. It does not, however, do this by providing a Rust API or DSL (domain-specific language) for building queries. Instead, it provides macros that take regular SQL as input and ensure that it is valid for your database. The way this works is that SQLx connects to your development DB at compile time to have the database itself verify (and return some info on) your SQL queries. This has some potentially surprising implications: • Since SQLx never has to parse the SQL string itself, any syntax that the development DB accepts can be used (including things added by database extensions) • Due to the different amount of information databases let you retrieve about queries, the extent of SQL verification you get from the query macros depends on the…