transact-rs/sqlx
70.1
Strong · 27 September 2026
56.4k
lines of production code
Rust
primary language
4
measurements over time
What this system is
SQLx is a type-safe Rust SQL toolkit that provides compile-time verified database access for PostgreSQL, MySQL, SQLite, and MSSQL. It features a unified \Any\ driver for runtime database selection, a robust CLI for managing migrations and database lifecycles, and extensive support for complex data types, JSON, and geometric data. The system emphasizes safety through strict SQL checks, reversible migrations with checksum validation, and comprehensive integration testing infrastructure.
How it got here
2019–2020 — modular architecture and driver expansion
41 changes.
The project underwent a major architectural restructuring, splitting the codebase into distinct crates for core functionality, macros, and individual database drivers like PostgreSQL, MySQL, and SQLite. This period introduced the generic 'Any' driver for runtime database selection, expanded type support with new adapters, and implemented a robust, reversible migration system with checksum validation. Comprehensive integration testing infrastructure was established using Docker, alongside new CLI capabilities and extensive example applications to demonstrate the library's expanded features.
2021–2023 — driver refactoring and testing infrastructure
39 changes.
This period focused on a comprehensive architectural overhaul of the MySQL, PostgreSQL, and SQLite drivers, restructuring their internal protocols, connection handling, and type mappings for improved modularity and performance. Concurrently, the project established a robust testing framework with isolated database fixtures and expanded the example suite to demonstrate advanced usage patterns like transactions, external SQL files, and real-time chat.
2024–2026 — Postgres type support and sqlx.toml configuration
9 changes.
This period focused on expanding PostgreSQL support by adding built-in mappings for geometric and IP network types, alongside introducing the sqlx.toml configuration file to manage complex multi-database and multi-tenant setups. The work also included adding comprehensive examples for these new features, enforcing license compliance, and refining macro environment variable handling.
Features
Add MySQL length-encoded integer and string serialization helpers
The MySQL driver now includes dedicated I/O utilities for handling MySQL's length-encoded data format. New \MySqlBufExt\ and \MySqlBufMutExt\ traits allow reading and writing length-encoded integers, strings, and byte sequences, ensuring correct protocol encoding for values of varying sizes. This change supports more robust and accurate communication with MySQL servers by properly handling the variable-length encoding scheme used in the MySQL binary protocol.
sqlx-mysql/src/io · high confidence
Add MySQL todos example with clap CLI and sqlx
A new example application for MySQL has been added, demonstrating how to build a command-line todo manager using the clap library for argument parsing and sqlx for database interactions. The application supports adding new todos, marking existing ones as done, and listing all tasks, with specific handling for MySQL's boolean storage format (TINYINT(1)).
examples/mysql/todos · high confidence
Add PostgreSQL JSON example with dynamic fields
A new example demonstrating how to store and retrieve JSON data in PostgreSQL using sqlx. The example includes a database migration to create a table with a JSONB column, and a CLI application that allows users to add people with dynamic extra fields (via serde's flatten feature) and list all stored records.
examples/postgres/json · high confidence
Add example for external SQL query files
A new example located at examples/postgres/files demonstrates how to store and execute SQL queries from external files using the \query\_file!\ and \query\_file\_as!\ macros. This approach allows users to encapsulate SQL logic in separate \.sql\ files, which can assist with tooling like intellisense, while the Rust code handles connection pooling via \dotenvy\ and maps results to structs.
examples/postgres/files · high confidence
Add mockable-todos example with testable Postgres integration
A new 'mockable-todos' example has been added to demonstrate structuring a Rust application for testability by separating business logic from the database layer. The example includes a \TodoRepo\ trait annotated with \mockall\ to allow unit testing of the command handling logic without a live database, alongside a \PostgresTodoRepo\ implementation using \sqlx\. It provides a complete setup with a \docker-compose.yml\ for running Postgres, a \.env.example\ for configuration, SQL migrations, and a CLI interface built with \clap\ to add, complete, and list todos.
examples/postgres/mockable-todos · high confidence
Add support for ipnet and ipnetwork types in PostgreSQL
Users can now map the \ipnet\ and \ipnetwork\ Rust crates to PostgreSQL's \inet\ and \cidr\ column types. This change introduces type implementations for \IpNet\/\Ipv4Net\/\Ipv6Net\ and \IpNetwork\/\Ipv4Network\/\Ipv6Network\, enabling seamless encoding and decoding of IP network ranges. It also adds support for \IpAddr\ (IPv4 and IPv6) by mapping it to the respective network types with full prefix lengths (32 for IPv4, 128 for IPv6), ensuring lossless conversion. The \ipnetwork\ implementation is prioritized when both features are enabled to maintain backward compatibility.
sqlx-postgres/src/types/ipnet, sqlx-postgres/src/types/ipnetwork · high confidence
Added Postgres transaction example
The examples/postgres/transaction directory now includes a runnable example demonstrating how to manage database transactions with Postgres. It provides a migration to create a todos table and source code that illustrates explicit rollback, implicit rollback (via drop), and commit scenarios, showing how to insert and verify data within an uncommitted transaction.
examples/postgres/transaction · high confidence
Added SQLite serialize/deserialize example
A new example demonstrating how to serialize an SQLite database connection into a buffer and deserialize it into a new connection, allowing users to snapshot and restore database state in memory.
examples/sqlite/serialize · high confidence
Added example runner script and documentation
The examples directory now includes a README explaining the requirement for the sqlx-cli tool, a .gitignore to exclude SQLite database files, and a new Python script (x.py) that automates the setup, migration, and verification of example projects across MySQL, Postgres, and SQLite.
examples · high confidence
Expose network socket types in sqlx-core
The sqlx-core crate now explicitly exports network-related types, including \WriteBuffer\, \Socket\, \BufferedSocket\, and connection functions like \connect\_tcp\ and \connect\_uds\. This change makes these internal networking components available for external use, allowing users to interact with the underlying socket abstractions directly.
sqlx-core/src/net · high confidence
Implement MySQL binary protocol statement handling
The MySQL driver now implements the binary protocol for prepared statements, replacing or supplementing the text protocol. This change introduces new modules in \sqlx-mysql/src/protocol/statement\ to encode and decode \COM\_STMT\_PREPARE\, \COM\_STMT\_EXECUTE\, and \COM\_STMT\_CLOSE\ commands, as well as parse \PrepareOk\ responses and binary result rows (\BinaryRow\). Users benefit from improved performance and support for binary-encoded data types when executing prepared statements.
sqlx-mysql/src/protocol/statement · high confidence
Implement MySQL connection phase protocol handling
Added the core MySQL connection phase implementation in \sqlx-mysql/src/protocol/connect\, introducing modules for handshake (\handshake.rs\), handshake response (\handshake\_response.rs\), SSL request (\ssl\_request.rs\), and authentication switching (\auth\_switch.rs\). This enables the client to correctly parse server handshakes (including MySQL 8.0 and MariaDB 10.4.7 variants), encode handshake responses with proper capability flags and authentication data, and handle \AUTH\_SWITCH\ requests, including support for the \mysql\_clear\_password\ plugin with specific handling for AWS Aurora IAM scenarios.
sqlx-mysql/src/protocol/connect · high confidence
Implement Postgres type mapping for chrono Date, Time, and DateTime
Adds support for encoding and decoding \chrono\ date, time, and datetime types in PostgreSQL. The implementation maps \NaiveDate\ to the Postgres \DATE\ type, \NaiveTime\ to \TIME\, and \NaiveDateTime\/\DateTime\ to \TIMESTAMP\/\TIMESTAMPTZ\. It handles both binary and text formats, ensuring correct conversion between Postgres internal representations (days since epoch for dates, microseconds for times) and \chrono\ types, while also handling timezone conversions for \DateTime\<Utc\>\ and \DateTime\<Local\>\.
sqlx-postgres/src/types/chrono · high confidence
Initial implementation of Postgres type mappings in sqlx-postgres
The \sqlx-postgres/src/types\ module has been introduced to provide the foundational type mapping layer for the Postgres driver. This change adds support for encoding and decoding a wide range of PostgreSQL data types, including standard numeric types (integers, floats, \BigDecimal\), text and binary data (\String\, \Vec\<u8\>\, \BitVec\), JSON/JSONB, and specialized Postgres types such as \citext\, \hstore\, \cube\, \interval\, and \lquery\. It also implements the \PgHasArrayType\ trait and associated logic to enable seamless handling of arrays for these types, allowing users to bind and retrieve Rust collections directly against Postgres array columns.
sqlx-postgres/src/types · high confidence
Introduce \`sqlx.toml\` configuration for macros and migrations
SQLx now supports a \sqlx.toml\ file (behind the \sqlx-toml\ feature) to configure the \query!\ macros and \sqlx-cli\ migrations. Users can now override the database URL environment variable, specify preferred crates for date/time and numeric types, define global or per-table SQL-to-Rust type overrides, and configure migration behavior such as the migrations directory, ignored characters, and handling of unrecognized \.sql\ files. SQLite extension loading can also be specified for the build-time tooling, though runtime connection configuration remains separate.
sqlx-core/src/config · high confidence
Introduce new low-level I/O abstractions for protocol encoding and decoding
The \sqlx-core/src/io\ module has been restructured to provide a new set of traits and types for handling network I/O. This includes \ProtocolEncode\ and \ProtocolDecode\ traits for serializing and deserializing protocol messages, \BufExt\ and \BufMutExt\ for convenient byte buffer manipulation, and \BufStream\ for buffering async read/write operations. Additionally, \WriteAndFlush\ ensures atomic write-and-flush operations, and \ReadBuf\ provides safe access to uninitialized buffer space. These changes lay the groundwork for more robust and efficient database protocol implementations.
sqlx-core/src/io · high confidence
Introduce runtime database driver selection via AnyConnection
Users can now connect to any supported database (PostgreSQL, MySQL, SQLite, etc.) using a single \AnyConnection\ type, where the specific backend is determined at runtime by the connection URL scheme. This change introduces the \AnyConnectionBackend\ trait and \AnyConnection\ struct in \sqlx-core/src/any/connection\, enabling dynamic driver dispatch while maintaining the standard \Connection\ and \Executor\ interfaces.
sqlx-core/src/any/connection · high confidence
Introduce the Any generic database driver
The \sqlx-core/src/any\ module now provides a generic database driver that allows selecting the underlying database (PostgreSQL, MySQL, SQLite, or MSSQL) at runtime based on the connection URL. This change introduces the \Any\ database type, \AnyConnection\, \AnyPool\, and \AnyConnectOptions\, along with implementations for argument encoding, row decoding, and type mapping for standard SQL types (integers, floats, booleans, text, and blobs). It also includes driver registration via \install\_drivers\ and optional migration support when the \migrate\ feature is enabled.
sqlx-core/src/any · high confidence
Introduction of a common LRU statement cache implementation
A new shared \StatementCache\ component has been added to \sqlx-core/src/common\, providing a Least Recently Used (LRU) cache for prepared statements backed by the \hashlink\ library. This implementation allows database drivers to reuse prepared statements, reducing the overhead of repeated preparation, and exposes configuration options such as cache capacity and enable/disable states to users.
sqlx-core/src/common · high confidence
Introduction of centralized test infrastructure and macros
The \sqlx-test\ crate has been added to provide a unified testing framework for the library. This includes helper functions to initialize environment variables via \dotenvy\ and configure logging, as well as utilities to create database connections and connection pools with specific configurations (such as testing connections before acquisition). Additionally, a suite of macros is introduced to simplify type testing across different database backends, allowing developers to easily verify type encoding and decoding for both prepared and unprepared queries.
sqlx-test/src · high confidence
MySQL type mapping and encoding/decoding implementation
The \sqlx-mysql/src/types\ module now provides comprehensive type conversions between Rust and MySQL/MariaDB. It implements \Type\, \Encode\, and \Decode\ for core Rust primitives including \bool\, signed/unsigned integers (\i8\–\i64\, \u8\–\u64\), floats (\f32\, \f64\), strings (\&str\, \String\, \Arc\<str\>\, \Box\<str\>\, \Cow\<str\>\, \Rc\<str\>\), and byte arrays (\&\[u8\]\, \Vec\<u8\>\, \Arc\<\[u8\]\>\, \Box\<\[u8\]\>\, \Cow\<\[u8\]\>\, \Rc\<\[u8\]\>\). It also adds support for IP addresses (\IpAddr\, \Ipv4Addr\, \Ipv6Addr\), JSON (\Json\<T\>\), and decimal types (\BigDecimal\, \rust\_decimal::Decimal\). Furthermore, it introduces a new \MySqlTime\ type to handle MySQL's signed \TIME\ values (intervals) and implements mappings for \chrono\ types (\DateTime\<Utc\>\, \DateTime\<Local\>\, \NaiveDate\, \NaiveDateTime\, \NaiveTime\, \TimeDelta\) and \time\ crate types (\Date\, \Time\, \PrimitiveDateTime\, \OffsetDateTime\, \Duration\), along with \Uuid\ (binary format) and a \Text\<T\>\ adapter for custom string-like types.
sqlx-mysql/src/types · high confidence
New Axum and SQLx social API example with integration tests
This location introduces a complete example application demonstrating how to build a social-media-style API using Axum and SQLx, complete with integration tests. The example provides HTTP endpoints for user registration and authentication, post creation and listing, and comment creation and listing, backed by PostgreSQL migrations for users, posts, and comments. It includes a README explaining the testing approach using \\#\[sqlx::test\]\, along with test fixtures and common test utilities to verify API behavior.
examples/postgres/axum-social-with-tests · high confidence
New MySQL TODOs example with database migrations
A new example application demonstrating a TODO list service backed by MySQL has been added to the examples/mysql directory. This example includes a SQL migration script to create the necessary database schema and a README with instructions for setting up the database, running migrations, and executing commands to add, complete, and list todos.
examples/mysql · high confidence
New MySQL protocol module with packet splitting and authentication support
The \sqlx-mysql/src/protocol\ module has been introduced, providing the core infrastructure for MySQL communication. This includes support for packet splitting to handle large payloads exceeding the maximum packet size, a comprehensive set of MySQL/MariaDB protocol capabilities flags, and authentication plugin handling (including \mysql\_clear\_password\). The module also defines internal structures for rows and packet encoding/decoding, establishing the foundation for the MySQL driver's network layer.
sqlx-mysql/src/protocol · high confidence
New PostgreSQL LISTEN/NOTIFY example demonstrating channel handling and streaming
Added a new example in \examples/postgres/listen\ that demonstrates how to use \PgListener\ to listen for notifications on multiple channels (\chan0\, \chan1\, \chan2\) and how to send notifications using \SELECT pg\_notify\. The example shows connecting via a \PgPool\, spawning a background task to emit notifications every 2 seconds, and processing incoming notifications both via a blocking \recv()\ loop and an asynchronous stream with a timeout. It also includes a README with usage instructions, requiring the \DATABASE\_URL\ environment variable.
examples/postgres/listen · high confidence
New PostgreSQL Todo example with CLI interface
Added a new example application in the \examples/postgres/todos\ directory that demonstrates a command-line tool for managing todos using PostgreSQL. The example includes a SQL migration to create the \todos\ table and a Rust implementation using \clap\ for argument parsing and \sqlx\ for database interactions. Users can now run commands to add new todos, mark existing ones as done, or list all todos, providing a concrete reference for integrating these libraries with a Postgres backend.
examples/postgres/todos · high confidence
New Postgres wire-protocol message types in sqlx-postgres
The \sqlx-postgres/src/message\ module now includes a comprehensive set of new structs for encoding and decoding PostgreSQL wire-protocol messages. This adds support for parsing authentication exchanges (including SASL, MD5, and cleartext passwords), backend key data, command completion tags, copy operations, data rows, and query descriptions. It also introduces new frontend message types for binding, parsing, describing, executing, and closing statements and portals, as well as handling flush, sync, and termination signals. Users benefit from a more complete and robust implementation of the Postgres extended query protocol.
sqlx-postgres/src/message · high confidence
New SQLite Todo example application
A new example application demonstrating a Todo list management tool using SQLite has been added. Users can now run this example to see how to perform CRUD operations (adding, marking as done, and listing todos) using the sqlx library with a SQLite database pool, utilizing clap for command-line argument parsing.
examples/sqlite/todos · high confidence
New SQLite examples for extensions and TODOs with migrations
Added two new example projects in the \examples/sqlite\ directory. The \extension\ example demonstrates how to load and use SQLite extensions (specifically \ipaddr\ and \uuid\ from sqlean) by configuring \sqlx.toml\ for CLI/macros and explicitly loading them via \SqliteConnectOptions\ at runtime. The \todos\ example provides a basic CRUD application setup using SQLx migrations to manage a TODO list.
examples/sqlite · high confidence
New \`sqlx::test\` macro with automatic database and migration management
The \src/macros\ module now includes documentation for the \sqlx::test\ attribute macro, which allows marking async test functions to automatically provision isolated test databases and apply migrations. Users can inject a \Pool\, \PoolConnection\, or \PoolOptions\ into their test signatures to interact with these live databases, with automatic cleanup on success and manual migration path configuration via attributes like \migrations\ or \migrator\.
src/macros · high confidence
New derive macros and query expansion entry points in sqlx-macros
The \sqlx-macros\ crate now exposes new procedural macro entry points that enable compile-time code generation for SQL queries and Rust type conversions. Users can now use \\#\[derive(Encode)\]\, \\#\[derive(Decode)\]\, \\#\[derive(Type)\]\, and \\#\[derive(FromRow)\]\ to automatically implement serialization, deserialization, type mapping, and row-to-struct conversion logic, respectively. Additionally, the \expand\_query\ function provides the underlying mechanism for query macros, while \migrate!\ and \\#\[test\]\ attributes are exposed for embedded migrations and test execution. These additions streamline database interaction by reducing boilerplate code for type handling and query execution.
sqlx-macros/src · high confidence
New examples for multi-database, multi-tenant, and preferred crate configuration
Added example projects demonstrating SQLx usage in multi-database and multi-tenant PostgreSQL setups, including payment management logic with connection pooling and migration handling. Additionally, introduced an example showcasing the \sqlx.toml\ configuration file, which allows users to explicitly specify preferred crates (such as \chrono\ over \time\ or \bigdecimal\ over \rust\_decimal\) to resolve type mapping conflicts caused by Cargo's feature unification.
(repo-wide) · high confidence
New interactive PostgreSQL chat example using ratatui
Added a new example application in examples/postgres/chat that demonstrates a real-time chat interface using PostgreSQL's LISTEN/NOTIFY mechanism. The application features a terminal user interface (TUI) built with ratatui and crossterm, allowing users to send and receive messages via a PostgreSQL channel (chan0). It requires a DATABASE\_URL environment variable to connect to the database and listens for notifications to update the chat history in real-time.
examples/postgres/chat · high confidence
New multi-database and multi-tenant examples demonstrating sqlx.toml configuration
Added two new example projects under \examples/postgres/\—\multi-database\ and \multi-tenant\—that showcase how to use the \sqlx.toml\ configuration file to manage complex database setups. The \multi-database\ example demonstrates a workspace structure where separate crates own distinct databases, using \sqlx.toml\ to define specific database URLs and custom type overrides for generated code. The \multi-tenant\ example illustrates a single-database, multi-schema approach, using \sqlx.toml\ to configure schema creation, migration table names, and schema-qualified type overrides. Both examples include full Rust implementations, SQL migrations, and setup scripts to help users understand how to structure their projects for type-safe database access in these scenarios.
(repo-wide) · high confidence
New type adapters and standard library support in sqlx-core
The \sqlx-core/src/types\ module now includes new type adapters and implementations to broaden supported Rust types. Users can wrap arbitrary types implementing \Display\ and \FromStr\ in the new \Text\<T\>\ adapter for storage as SQL text. The \Json\<T\>\ wrapper now implements \DerefMut\ and \AsMut\, allowing mutable access to the inner JSON value. Support for \NonZero\*\ integer types from the standard library is added, enabling direct mapping of non-zero integers to SQL numeric types. Additionally, the \bstr\ crate's \BString\ and \BStr\ types are supported under the \bstr\ feature flag, and \JsonRawValue\ encoding/decoding implementations are added for more flexible JSON handling.
sqlx-core/src/types · high confidence
SQLite connection layer refactored into modular components
The SQLite connection implementation has been restructured from a monolithic file into a set of specialized modules within \sqlx-sqlite/src/connection\. This change introduces dedicated modules for connection establishment (\establish.rs\), statement execution (\execute.rs\), and query description (\describe.rs\), while also adding support for custom collations (\collation.rs\), database serialization/deserialization (\deserialize.rs\), and preupdate hooks (\preupdate\_hook.rs\). The refactoring improves code organization and enables new capabilities such as custom collation ordering, in-memory database serialization, and detailed pre-update change tracking, all while maintaining the existing \SqliteConnection\ interface.
sqlx-sqlite/src/connection · high confidence
Support for Postgres geometric types (point, line, lseg, polygon, path, box, circle)
The \sqlx-postgres\ crate now includes built-in type mappings for all standard PostgreSQL geometric data types. Users can now read and write \point\, \line\, \lseg\ (line segment), \polygon\, \path\, \box\, and \circle\ values directly, with automatic encoding and decoding for both text and binary formats.
sqlx-postgres/src/types/geometry · high confidence
Architecture
MySQL connection implementation refactored into modular components
The MySQL connection logic in \sqlx-mysql/src/connection\ has been restructured from a monolithic file into distinct modules: \auth.rs\ handles authentication plugins (including \caching\_sha2\_password\, \mysql\_native\_password\, \sha256\_password\, and \mysql\_clear\_password\), \establish.rs\ manages the initial handshake and connection establishment, \executor.rs\ handles statement preparation and execution, \stream.rs\ manages the underlying network stream and packet handling, and \tls.rs\ handles TLS upgrades. This change improves code organization and maintainability without altering the external API or behavior.
sqlx-mysql/src/connection · high confidence
PostgreSQL driver extracted into standalone crate
The PostgreSQL driver has been separated from the main sqlx crate into its own dedicated \sqlx-postgres\ crate. This architectural change isolates the driver-specific implementation, including connection handling, type mappings, advisory locks, and the COPY protocol, allowing it to be maintained and versioned independently. Users will now need to add the \sqlx-postgres\ dependency explicitly to their projects to use PostgreSQL features.
sqlx-postgres/src · high confidence
Refactor MySQL text protocol into modular sub-modules
The MySQL text protocol implementation in \sqlx-mysql\ has been reorganized from a single monolithic file into distinct modules (\column\, \ping\, \query\, \quit\, \row\). This change introduces explicit definitions for column metadata (including flags and types), row decoding logic, and specific protocol commands (COM\_PING, COM\_QUERY, COM\_QUIT), improving code structure and maintainability without altering the external API.
sqlx-mysql/src/protocol/text · high confidence
Behavioural changes
Added internal async stream and string utilities
The \sqlx-core\ library now includes internal helper modules in \sqlx-core/src/ext\. This introduces a \try\_stream!\ macro and a \TryAsyncStream\ type, which provide a zero-dependency, safe implementation of asynchronous streaming to replace the external \async-stream\ crate, ensuring lock-step execution and avoiding unnecessary wakeups. Additionally, a \UStr\ (micro-string) type is added to allow cheap, reference-counted cloning of string data, supporting both static and shared string representations.
sqlx-core/src/ext · high confidence
CLI now exits with non-zero status on errors
The sqlx-cli binaries (both the direct \sqlx\ command and the \cargo-sqlx\ wrapper) now exit with code 1 when a command fails, instead of exiting with code 0. This ensures that scripts and CI pipelines can correctly detect command failures.
sqlx-cli/src/bin · high confidence
Connection pool internals refactored for improved fairness and liveness
The connection pool implementation has been restructured to enhance reliability and performance. The internal state is now managed by a dedicated \PoolInner\ struct, which uses crossbeam queues and atomic counters to track idle connections and pool size, avoiding race conditions and CPU spins during maintenance. Fairness in connection acquisition is now configurable via the \fair\ option in \PoolOptions\, allowing users to choose between strict FIFO ordering or potentially faster, less fair acquisition. Additionally, connection liveness is verified more robustly: connections are tested before acquisition (\test\_before\_acquire\) and pings are sent upon release to ensure they are still viable, preventing the use of stale connections. The pool also now supports parent-child relationships, where child pools can steal permits from a parent pool, and provides explicit methods to close connections gracefully or detach them from the pool lifecycle.
sqlx-core/src/pool · high confidence
Core traits and types restructured into modular source files
The \sqlx-core\ library has been refactored to organize its foundational components into distinct modules (\acquire\, \arguments\, \column\, \connection\, \database\, \decode\, \describe\, \encode\, \error\, \executor\, \from\_row\). This change introduces the \Acquire\ trait for generic connection and transaction acquisition, redefines the \Database\ trait to encapsulate driver-specific associated types (such as \Connection\, \Row\, and \Column\), and updates the \Executor\ trait to use \fetch\ and \fetch\_many\ for result streaming. Additionally, the \FromRow\ derive macro documentation and implementation have been updated to support new field attributes like \rename\_all\ and \flatten\, while error handling is standardized through the \Error\ enum and \DatabaseError\ trait.
sqlx-core/src · high confidence
Expanded derive macro attributes and JSON support in sqlx
The \sqlx::Type\, \FromRow\, \Encode\, and \Decode\ derive macros now support several new attributes: \rename\_all\ for consistent field/variant naming, \json\ (including \json(nullable)\) for handling JSON columns, \try\_from\ for custom type conversion during row decoding, and \skip\ to exclude fields from row mapping. Additionally, single-field structs can now be marked \transparent\ to delegate encoding/decoding to their inner type, and PostgreSQL array handling can be opted out of via \no\_pg\_array\.
sqlx-macros-core/src/derives · high confidence
Introduce structured migration system with reversible migrations and checksum validation
The migration subsystem has been restructured to support reversible migrations (using \.up.sql\ and \.down.sql\ file pairs) alongside simple single-file migrations, with the migration type automatically inferred from the filename. The system now validates previously applied migrations using SHA-384 checksums to detect accidental changes, and provides specific error types for issues such as version mismatches, missing versions, and dirty (partially applied) migrations. Users can now configure migration resolution to ignore specific characters (like whitespace) when calculating checksums, control whether unrecognized SQL files cause errors or warnings, and optionally skip database locking during migration execution.
sqlx-core/src/migrate · high confidence
Introduction of internal type-matching and error-specialization utilities
The library now includes internal modules \ty\_match\ and \spec\_error\ to improve compile-time type resolution and error handling for query macros. The \ty\_match\ module implements a specialization-like mechanism using autoref to correctly match parameter types (such as \&str\ vs \String\ or \Option\<T\>\ vs \T\) in \query!\ macros, ensuring better compiler errors. The \spec\_error\ module provides a way to wrap and display various error types (implementing \Debug\, \Display\, or \Any\) consistently within the macro-generated code. These changes support the macro system's ability to infer and validate SQL parameter types at compile time.
src · high confidence
License files added and env loading enforcement via Clippy
The sqlx-macros-core crate now includes explicit LICENSE-APACHE and LICENSE-MIT files, replacing previous symlinks to ensure proper license distribution. Additionally, a new clippy.toml configuration disallows the use of std::env::var in favor of the crate's internal env() function, which ensures that environment variable changes are properly tracked and invalidated during macro expansion.
sqlx-macros-core · high confidence
License files added to SQLx crates
The sqlx-core, sqlx-macros, sqlx-mysql, sqlx-postgres, sqlx-sqlite, and sqlx-test crates now include explicit LICENSE-APACHE and LICENSE-MIT files. This change ensures that the full text of the Apache License 2.0 and MIT License is distributed with each crate, clarifying the dual-licensing terms for users and downstream projects.
(repo-wide) · high confidence
Major CLI restructuring and new database management commands
The \sqlx-cli\ source has been reorganized into distinct modules (\database\, \migrate\, \prepare\, \metadata\, \completions\, \opt\), introducing new \database create\, \database drop\, \database reset\, and \database setup\ subcommands for managing database lifecycles, alongside a \migrate revert\ command for rolling back migrations. The CLI now supports shell autocompletion via \clap\_complete\, allows disabling automatic \.env\ loading with \--no-dotenv\, and improves the \prepare\ workflow by using \cargo check\ consistently and storing temporary query files in the workspace target directory. Additionally, the \migrate add\ command now links to the correct documentation version and supports reversible migrations, while the \migrate info\ command displays checksum mismatches for installed migrations.
sqlx-cli/src · high confidence
MySQL connection options now support timezone configuration and flexible SSL modes
The MySQL driver's connection options have been expanded to allow users to specify a timezone via the \timezone\ query parameter (e.g., \?timezone=%2B08:00\) in the connection URL, which is then applied to the session to ensure consistent timestamp handling. Additionally, the \ssl\_mode\ parameter is now fully supported in URLs, allowing users to explicitly control SSL negotiation behavior (Disabled, Preferred, Required, VerifyCa, or VerifyIdentity) rather than relying solely on defaults. The connection establishment process also now configures SQL modes (such as \PIPES\_AS\_CONCAT\ and \NO\_ENGINE\_SUBSTITUTION\) and character set settings (\SET NAMES\) automatically based on the provided options, ensuring the connection behaves as expected for standard SQL operations.
sqlx-mysql/src/options · high confidence
MySQL driver refactored into a standalone crate with unified Any driver support
The MySQL driver has been extracted into its own \sqlx-mysql\ crate, separating it from the core library. This change introduces a new \AnyConnectionBackend\ implementation for \MySqlConnection\, allowing the MySQL driver to be used seamlessly through the generic \Any\ driver interface. The driver now uses \SqlStr\ for SQL strings, implements a unified \Debug\ format for rows, and handles MySQL-specific error codes (including MariaDB constraints) and collation logic more robustly. Users can now interact with MySQL via the unified \Any\ API or directly via the new \sqlx-mysql\ crate.
sqlx-mysql/src · high confidence
New MySQL response packet parsers for EOF, Error, OK, and Status
The MySQL driver now includes dedicated parsers for standard server response packets (EOF, Error, OK, and Status flags) in the \sqlx-mysql\ crate. This adds robust decoding for command completion and error conditions, including validation of packet headers and length checks to prevent panics on truncated data, while also introducing unit tests to verify correct parsing of various packet formats.
sqlx-mysql/src/protocol/response · high confidence
New buffered socket abstraction with TCP\_NODELAY enabled
The \sqlx-core\ networking layer now uses a new \BufferedSocket\ wrapper that manages read and write buffers (defaulting to 8KB) to reduce system calls during I/O operations. This change also explicitly enables the \TCP\_NODELAY\ option on new TCP connections, which disables Nagle's algorithm to reduce latency for small packets. The \Socket\ trait and its implementations have been refactored to support this buffering and async I/O pattern, providing a more efficient and lower-latency connection experience.
sqlx-core/src/net/socket · high confidence
PostgreSQL connection options restructured with new URL parsing and SSL support
The \sqlx-postgres\ crate now uses a new \PgConnectOptions\ implementation in \sqlx-postgres/src/options\ that supports parsing connection URLs with percent-decoded credentials and database names, and allows setting client SSL certificates and keys from bytes via environment variables or URL parameters. The default \extra\_float\_digits\ is changed from 3 to 2, and the \.pgpass\ file warning is demoted to a debug message. The module also documents that the session \TimeZone\ is set to \UTC\ on connection, which may affect timestamp functions compared to \psql\.
sqlx-postgres/src/options · high confidence
Postgres time type handling now discards subsecond precision
The \sqlx-postgres\ crate's implementation for decoding PostgreSQL \TIME\ values has been updated to strip subsecond precision, aligning with the database's native \TIME\ type which does not store fractional seconds. This behavioral change ensures that when reading \TIME\ columns, any subsecond data sent by the server is ignored, preventing potential mismatches or errors during decoding.
sqlx-postgres/src/types/time · high confidence
Refactor PostgreSQL protocol handling with new ID and buffer utilities
The \sqlx-postgres\ crate introduces a dedicated I/O module (\sqlx-postgres/src/io\) that refactors how statement and portal identifiers are managed and encoded for the PostgreSQL protocol. This change adds \StatementId\ and \PortalId\ types to handle named and unnamed identifiers, ensuring consistent naming prefixes (\sqlx\s\\ and \sqlx\p\\) and NUL-terminated encoding. It also provides a \PgBufMutExt\ trait for \Vec\<u8\>\ to simplify writing length-prefixed messages, which are required by the PostgreSQL protocol for variable-sized data. This internal restructuring improves protocol handling robustness and reduces dead code.
sqlx-postgres/src/io · high confidence
Refactored PostgreSQL connection handling and improved nullability inference
The PostgreSQL connection logic in \sqlx-postgres/src/connection\ has been restructured into dedicated modules (establish, executor, describe, resolve, sasl, stream, tls) to improve protocol handling and maintainability. A key behavioral improvement is the accurate detection of EXPLAIN support: the driver now checks for specific server parameters (CockroachDB, Materialize, QuestDB) and PostgreSQL version 12+ before forcing a generic query plan, preventing syntax errors on incompatible servers. Additionally, nullability inference for query results now uses \UNION ALL\ instead of \VALUES\ for better compatibility and correctly patches results using \EXPLAIN VERBOSE\ when available. The SASL authentication implementation now correctly applies \SASLprep\ to usernames and passwords, and the connection stream properly handles \UnexpectedEof\ when a server closes the connection during SSL negotiation.
sqlx-postgres/src/connection · high confidence
Refactored database introspection with connection caching and Postgres generic plan support
The \sqlx-macros-core\ database module has been restructured to improve query introspection reliability and performance. A new \DatabaseExt\ trait and \CachingDescribeBlocking\ implementation now cache database connections during compile-time query description, reducing overhead. For Postgres, the system now forces a generic query plan during description to provide more accurate nullability inference for parameterized queries, while explicitly skipping this behavior for incompatible drivers like CockroachDB. Additionally, the module now drops cached connections upon encountering I/O or protocol errors to prevent stale state.
sqlx-macros-core/src/database · high confidence
Refactored macro core with new path resolution and migration handling
The \sqlx-macros-core\ crate has been restructured to improve how paths are resolved and migrations are processed. A new \common.rs\ module introduces \resolve\_path\, which enforces that migration and fixture paths must be relative to the Cargo manifest directory, rejecting absolute paths and unsupported relative-to-file paths. The \migrate.rs\ module now handles migration expansion with better error reporting for file I/O issues and uses \SqlStr\ for SQL content. The \test\_attr.rs\ module has been updated to support new argument parsing for fixtures and migrations, allowing more flexible configuration of test database setups via attributes.
sqlx-macros-core/src · high confidence
Refactored query macro internals and improved offline caching
The query macro implementation has been restructured into modular files (args, cache, data, input, metadata, output) to improve maintainability. A new file-mtime-based caching system (MtimeCache) ensures that query metadata is automatically invalidated when source files change, preventing stale compilation results. Offline query data is now stored with atomic file creation to prevent corruption from concurrent builds, and environment variable loading is restricted to the workspace root to avoid leaking configuration from parent directories.
sqlx-macros-core/src/query · high confidence
Runtime-generic database driver with explicit driver installation
The \any\ module now provides a runtime-generic database driver that allows connections to different database types (MySQL, PostgreSQL, SQLite) based on connection options. To prevent panics when using \AnyConnection\ or \AnyPool\, users must explicitly install drivers at runtime by calling \install\_default\_drivers()\ or \install\_drivers()\. This change introduces a new \install\_drivers\_note.md\ documentation file and re-exports core types like \AnyConnection\, \AnyPool\, and \Any\ from \sqlx\_core\, ensuring that the driver installation step is clearly documented and enforced.
src/any · high confidence
SQLite driver restructured for SQLx 0.9.0 with new core traits and migration support
The SQLite driver has been refactored to align with the SQLx 0.9.0 architecture, introducing new core types such as SqliteArguments, SqliteColumn, and SqliteTypeInfo that implement the updated Database and Arguments traits. This change includes the addition of an Any driver implementation for SqliteConnection, enabling polymorphic database access, and introduces support for \no\_tx\ migrations, allowing migration scripts to run outside of transactions. The driver also now exposes a custom REGEXP function for SQLite queries and updates the error handling to use \from\_utf8\_lossy\ for safer message decoding.
sqlx-sqlite/src · high confidence
SQLite statement handling refactored with new column metadata and multi-statement support
The SQLite driver's statement module has been restructured to improve how column information is exposed and how multiple SQL statements are processed. A new \StatementHandle\ struct now wraps the raw SQLite statement pointer, providing safer and more explicit access to column metadata (name, origin, type) and query execution state. The \SqliteStatement\ struct now uses \SqlStr\ for SQL text storage and exposes column details via the standard \Statement\ trait. Additionally, a \VirtualStatement\ implementation allows executing multiple SQL statements in a single query by splitting on semicolons and managing a sequence of prepared statements, while an \unlock\_notify\ module ensures proper synchronization when waiting for database locks to be released.
sqlx-sqlite/src/statement · high confidence
SQLite type mapping restructured with new integer decoding and expanded type support
The SQLite type system has been reorganized into dedicated modules (bool, bytes, chrono, float, int, json, str, text, time, uint, uuid) to improve clarity and maintainability. A key behavioral change is that all integer decoding now uses \int64()\ as an intermediate step, which fixes silent truncation bugs for smaller integer types (i8, i16, u8, u16) and ensures correct handling of values that exceed 32-bit ranges. The library now supports a broader set of Rust types, including \bool\, \Arc\<str\>\, \Arc\<\[u8\]\>\, \Rc\<str\>\, \Rc\<\[u8\]\>\, \Box\<str\>\, \Box\<\[u8\]\>\, and \Cow\ variants for both strings and bytes. Date/time support has been expanded and refined for both \chrono\ and \time\ crates, with detailed documentation on format compatibility and timezone handling. Additionally, \Text\<T\>\ adapter support allows custom types to be stored as text, and UUID support now includes \Simple\ and \Hyphenated\ formats.
sqlx-sqlite/src/types · high confidence
SQLx 0.9.0 release and repository transfer
This release marks the transition of the SQLx repository to the new \transact-rs\ GitHub organization and introduces significant breaking changes, including a new \sqlx.toml\ configuration format, stricter SQL safety checks via \SqlSafeStr\, and updated MSRV requirements. The \Cargo.lock\ is no longer tracked in Git to simplify dependency management, and several runtime/TLS feature combinations have been removed in favor of separate feature flags.
(repo-wide) · high confidence
Structured SQLite pragma configuration and connection options
The SQLite connection options module has been refactored to provide strongly-typed, type-safe configuration for key SQLite pragmas. Users can now explicitly set \auto\_vacuum\, \journal\_mode\, \locking\_mode\, and \synchronous\ settings via dedicated enums (e.g., \SqliteJournalMode::Wal\) rather than raw strings. The connection establishment process now executes these pragmas in a strict, documented order (e.g., ensuring \locking\_mode\ is set before \journal\_mode\) to prevent configuration conflicts and ensure correct database initialization. Additionally, the module introduces an \optimize\_on\_close\ option to automatically run \PRAGMA optimize;\ when a connection is closed, and improves URL parsing to correctly handle in-memory databases and query parameters like \mode\ and \cache\.
sqlx-sqlite/src/options · high confidence
Unified TLS configuration with inline certificate support
The \sqlx-core\ TLS layer now introduces a \CertificateInput\ enum that allows users to provide root and client certificates either via file paths or as inline PEM strings, simplifying configuration for environments where certificates are managed in memory. This change also standardizes the TLS configuration interface (\TlsConfig\) across both \rustls\ and \native-tls\ backends, ensuring consistent handling of options like \accept\_invalid\_certs\ and client authentication regardless of the underlying TLS library.
sqlx-core/src/net/tls · high confidence
Unified runtime abstraction for async operations
The \sqlx-core/src/rt\ module now provides a unified abstraction layer for async runtime operations, allowing SQLx to support multiple async runtimes (Tokio, async-std, smol, and async-global-executor) via feature flags. This change introduces a centralized \JoinHandle\ enum and runtime-agnostic functions for \timeout\, \sleep\, \spawn\, \spawn\_blocking\, and \yield\_now\, which delegate to the appropriate underlying runtime implementation based on the enabled features. It also includes specific socket implementations for \async\_io\ and \tokio\ to ensure consistent network I/O behavior across different async environments.
sqlx-core/src/rt · high confidence
Test coverage
Add PostgreSQL test infrastructure with race-condition-safe cleanup; Add integration tests for MSSQL driver; Added MySQL integration tests and test infrastructure; Added MySQL test infrastructure for database lifecycle management; Added SQLite describe performance benchmarks; Added SQLite testing infrastructure and path conversion tests; Added UI tests for MySQL chrono feature gating; Added UI tests for Postgres query macro error handling; Added UI tests for optional Postgres feature gating; Added comprehensive test suite for SQLite; Added integration tests for SQLx CLI migration commands; Added integration tests for the Any database driver; Added reversible migration test fixtures; Added testing utilities for database fixtures and test context management; Added tests for SQL migration whitespace handling; Added tests for the \migrate!\ macro and migration resolution; Comprehensive test suite for PostgreSQL integration; New local integration testing infrastructure with Docker and test runner.
Dependencies
SQLx 0.9.0 release with Rust 1.94 MSRV and workspace restructuring
SQLx has been updated to version 0.9.0, raising the minimum supported Rust version (MSRV) to 1.94.0 and migrating the project to the 2021 edition. This release introduces a comprehensive workspace restructuring, splitting the codebase into distinct crates (\sqlx-core\, \sqlx-macros\, \sqlx-macros-core\, \sqlx-cli\, and driver-specific crates like \sqlx-postgres\, \sqlx-mysql\, \sqlx-sqlite\) to improve modularity. The dependency graph has been significantly updated, including a major upgrade to \rustls\ 0.23.24 for TLS support, \clap\ 4.4.7 for the CLI, and \tokio\ 1.25.0 across examples. New features include \sqlx-toml\ configuration support, SQLite extension loading, and improved offline mode capabilities, while the \sqlx-cli\ now supports \cargo sqlx\ invocation and completion.
(dependencies) · high confidence
Housekeeping
sqlx-cli documentation and license files added
The sqlx-cli directory now includes the README.md, LICENSE-APACHE, and LICENSE-MIT files, providing installation instructions, usage examples for database and migration commands, and licensing terms for the CLI tool.
sqlx-cli · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 41 → 70 (+29.0)
- Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 98 → 85 (-12.5)
- Architecture 69 → 99 (+29.5)
- Maturity 59 → 58 (-1.2)
- Readiness 19 → 73 (+54.8)
- Security 54 → 89 (+35.3)
Resolved (64)
- Coverage not measured — test suite did not build
- Critical IaC: DS-0031 (tests/mysql/Dockerfile)
- Dimension evaluation failed
- High IaC: DS-0002 (tests/mssql/mssql-2017.dockerfile)
- High IaC: DS-0002 (tests/mysql/Dockerfile)
- High IaC: DS-0002 (tests/postgres/Dockerfile)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- …and 44 more
New (217)
- Change coupling clique: lib.rs, lib.rs, lib.rs (sqlx-mysql/src/lib.rs)
- Change coupling: decode.rs ↔ encode.rs (sqlx-macros-core/src/derives/decode.rs)
- Change coupling: decode.rs ↔ type.rs (sqlx-macros-core/src/derives/decode.rs)
- ClassTooLong: PgType (sqlx-postgres/src/type_info.rs)
- Concentrated knowledge decay
- ConnectionWorker::establish (cognitive 92) (sqlx-sqlite/src/connection/worker.rs)
- ConnectionWorker::establish (cyclomatic 43) (sqlx-sqlite/src/connection/worker.rs)
- Dependency hygiene PARTLY measured — Cargo dependencies read, no committed lock to grade for currency
- Documentation: no installation or build instructions (README.md)
- Documentation: no project overview (README.md)
- Documentation: no project overview (examples/sqlite/todos/README.md)
- Duplicate intent across modules: MigrateDatabase (in sqlx_core.migrate.migrate) and AnyMigrateDatabase (in sqlx_core.any.driver) both expose force_drop_database. While one is generic and one is 'any', the naming and intent are nearly identical. If AnyMigrateDatabase is a wrapper or specific implementation, it should likely delegate or be an alias, not a parallel public API surface unless they serve distinctly different driver contexts. However, given AnyMigrateDatabase is in the any module, it might be a trait implementation. The bigger issue is the naming consistency with drop_database vs force_drop_database.
- Duplicate intent: Both MigrateDatabase and AnyMigrateDatabase expose drop_database. This suggests a lack of clear hierarchy or delegation between the generic database migration trait and the 'any' driver specific implementation.
- Duplicate method signature: Two methods named try_parse exist with identical signatures (same name, same parameter type str, same return type). The only difference is the parameter name (name vs _name), which is irrelevant in Rust signatures. This indicates a copy-paste error or unresolved conflict.
- Duplicated block (10 lines × 2) (sqlx-postgres/src/types/geometry/path.rs)
- Duplicated block (10 lines × 2) (sqlx-postgres/src/types/lquery.rs)
- Duplicated block (11 lines × 2) (sqlx-mysql/src/migrate.rs)
- Duplicated block (11 lines × 2) (sqlx-postgres/src/advisory_lock.rs)
- Duplicated block (11 lines × 2) (sqlx-postgres/src/migrate.rs)
- Duplicated block (11 lines × 3) (sqlx-macros/src/lib.rs)
- …and 197 more
Changes since last survey
- 23 commits — 15 feature/other, 8 fixes
By area
- sqlx-postgres/src — 6 commits
- sqlx-core/src — 5 commits
- sqlx-mysql/src — 3 commits
- sqlx-cli/src — 2 commits
- sqlx-sqlite/src — 2 commits
- (root) — 1 commit
- examples/README.md — 1 commit
- sqlx-cli/LICENSE-APACHE — 1 commit
- sqlx-sqlite/Cargo.toml — 1 commit
- src/macros — 1 commit
Notable commits
- fix: Fix Any type/close handling, MySQL time signs, SQLite plans, and macro docs (#4359)
- fix: Fix PostgreSQL memory leak when statement cache is disabled (#4337)
- fix: bugfix: streamline and fix AnyQueryResult::last_insert_id() for SQLite (#4205)
- fix: fix(pool): prevent num_idle underflow that wedges maintenance in a CPU spin (#4289)
- fix: fix(postgres): return UnexpectedEof when server closes connection at SSLRequest (#4395) (#4406)
- fix: fix(postgres): roll back a transaction cancelled during BEGIN (#4394)
- fix: fix(sqlite): correct sub-second decoding of pre-epoch REAL datetimes (#4340)
- fix: fix(sqlite): don't dereference a NULL declared type in column_nullable (#4374)
- change: Add Infinity check functions to PgInterval (#4295)
- change: Error on .sql migration files that don't match the expected filename format (#4367)
- change: Improve prepare invocation error (#4392)
- change: Replace license symlinks with copies (#4388)
- change: Reuse the TLS connector across connection attempts (#4242)
- change: Update README.md versions to 0.9 (#4377)
- change: [PostgreSQL] Invalided stale prepared statements (#4375)
- change: chore: Add README to examples (#4264)
- change: docs(macros): document that bind parameter nullability is not compile-checked (#4345)
- change: docs(postgres): document default TimeZone=UTC session behavior (#4344)
- change: docs: clarify Pool::size and Pool::num_idle (#4398)
- change: feat: add ability to set or unset the CLIENT_FOUND_ROWS flag (#4334)
- …and 3 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
transact-rs/sqlx was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 27 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit b54008a329541c0ce230d8b203e0c00fc8e8ea48 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-d00c643c3f66.