sqlx for compile-time checked SQL queries with async

4566
0

Sqlx is a pure-Rust SQL client that checks queries at compile time against your database schema. The query! macro connects to your DB during compilation and validates that columns and types match. This catches typos and schema drift before runtime. It supports Postgres, MySQL, and SQLite, with async drivers. I use query_as! to map rows directly into structs. For dynamic queries, query() (no macro) falls back to runtime checks. Connection pooling is built-in via PgPool. The compile-time verification is the killer feature: refactoring is safe because the compiler tells you which queries break. For migrations, I use sqlx-cli. It's more ergonomic than ORMs while staying close to SQL.