Nicolas Marshall

Nicolas
Marshall

All posts

Rust: choosing a database library

Choosing a database library in Rust is about understanding the trade-offs between control, safety, and convenience. The ecosystem offers a range of options, from high-level ORMs to low-level drivers.

Database → Library Options

Database Library Options
PostgreSQL Diesel, Diesel-async, SQLx, SeaORM, SeaQuery, Toasty
MySQL Diesel, Diesel-async, SQLx, SeaORM, SeaQuery, Toasty
SQLite Diesel, Diesel-async, SQLx, SeaORM, SeaQuery, Toasty
Turso Toasty
MongoDB Official MongoDB Rust driver
DynamoDB AWS SDK for Rust, Toasty, Dynarust

Choosing a Library

diesel diesel-async sqlx seaquery toasty seaorm
Query builder ✅ ✅ ⛔ (manual strings) ✅ ✅ ✅
Type-safe queries ✅ ✅ ✅ ⛔ (no compile-time schema check) 🟡 schema/migrations from struct ✅
Dynamic queries 🟡 depends 🟡 depends ✅ ✅ ✅ 🟡 depends
Async ⛔ ✅ ✅ ✅ ✅ ✅
Performance 🟡 depends ✅ often good ✅ often good ✅ often good ✅ often good ✅ often good
  • Diesel — Compile-time query validation and safety. Synchronous by default, use diesel-async for async.
  • SQLx — Async SQL toolkit with compile-time checked raw SQL. Maximum control, no query builder.
  • SeaQuery — Standalone query builder. Good for dynamic queries where schema isn’t known at compile time.
  • Toasty — Only library with Turso support. Supports SQL and NoSQL (DynamoDB).
  • SeaORM — Async-first ORM built on sqlx. Productivity-focused, familiar to Django/Rails devs.

Connection Pooling

Library Notes
deadpool Dead-simple async connection pool
r2d2 Generic pool, often used with sync drivers