Skip to content
rusthacks.dev
Topic

Databases

Talking to Postgres, MySQL and SQLite from Rust with SQLx and Diesel, and schemas that age well.

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

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.