Skip to content
rusthacks.dev

Tag

sqlx

14 posts

Flat illustration for the post “Actix Web With SQLx and Connection Pools in One Repository”, composed around database.
WebGuide

Actix Web With SQLx and Connection Pools in One Repository

Wire Actix Web 4 to a SQLx 0.9 pool the right way: build the pool once outside the factory closure, share it as web::Data, map errors with ResponseError, and see the 8 versus 28 connection difference when it goes wrong.

16 min read
Flat illustration for the post “Per Test Databases in Rust With SQLx Test Attribute”, composed around testing.
Databases

Per Test Databases in Rust With SQLx Test Attribute

The sqlx::test attribute creates a fresh database for each test, runs your migrations, hands you a pool and drops it afterwards. Learn fixtures, the DATABASE_URL requirement, parallelism and common errors.

3 min read
Flat illustration for the post “SQLx Error Handling and Unique Violation Detection”, composed around database.
Databases

SQLx Error Handling and Unique Violation Detection

Turn a PostgreSQL unique violation into a friendly conflict instead of a 500. Check is_unique_violation on the database error, read the constraint name and map foreign key errors too.

3 min read