sqlx
Installation
SKILL.md
sqlx — Async SQL Toolkit for Rust
sqlx is an async-first, pure-Rust SQL toolkit with compile-time query checking. It supports PostgreSQL, MySQL, and SQLite without a DSL — you write raw SQL, and sqlx validates it against a live database at compile time.
Crate Architecture
| Module | Purpose |
|---|---|
sqlx::postgres |
PostgreSQL driver (PgPool, PgConnection, PgListener) |
sqlx::mysql |
MySQL driver (MySqlPool, MySqlConnection) |
sqlx::sqlite |
SQLite driver (SqlitePool, SqliteConnection) |
sqlx::any |
Database-agnostic driver (AnyPool) — no compile-time checking |
sqlx::query_builder |
Runtime dynamic query construction (QueryBuilder) |
sqlx::migrate |
Migration framework (migrate! macro, Migrator) |
sqlx::types |
Type wrappers (Json<T>, Text<T>) |
Quick Start: Minimal Dependency Setup
Always include at least one database driver and a runtime feature. Without a runtime feature, the pool will panic at runtime.