$ show boostorg/mysql
Boost.MySQL is a high-quality, production-ready C++11 client library for MySQL and MariaDB, built on top of Boost.Asio. It provides both synchronous and asynchronous database access with a modern, type-safe interface. The library features a sans-I/O architecture that separates protocol logic from transport, enabling testability and flexibility. Key capabilities include connection pooling with automatic health checks, client-side SQL formatting to prevent injection, prepared statements, pipeline batching, and a static interface using Boost.Describe or Boost.Pfr for compile-time row mapping. The codebase demonstrates strong engineering practices: extensive unit and integration tests, fuzzing, thread-safety verification, and benchmarks against native MySQL clients. It is an official Boost library, actively maintained with a large community.
The LLM identified 5 files worth highlighting for reuse:
Implements the sans-I/O connect algorithm as a resumable state machine. It yields next_action (read, write, connect) and is driven by an engine. This pattern is reusable for any protocol that requires non-blocking I/O with complex state transitions, and demonstrates clean separation of protocol logic from transport.
A CRTP-based sans-I/O state machine for managing a single connection's lifecycle within a pool (idle, in-use, reset, ping, error recovery). It is generic and could be extracted for any connection pooling system that needs to track and recycle connections with health checks.
Provides a client-side SQL formatting system with compile-time specifier parsing, escaping, and custom formatter support. The design is extensible and safe, preventing SQL injection. The pattern of a formatter customization point and incremental output is reusable for any templated string formatting library.
Defines type traits for mapping C++ types to MySQL column types, enabling compile-time validation and parsing of query results. The pattern of a traits-based compatibility matrix and runtime parsing is reusable for any database client that wants to offer a static interface.
A test helper framework for step-by-step testing of sans-I/O algorithms. It provides a mock stream with breakpoints, allowing deterministic simulation of reads/writes and verification of algorithm state transitions. This pattern is reusable for testing any state-machine-based async code without real I/O.