Databases

From Rust Community Wiki
Jump to navigation Jump to search

Rust support for databases occurs on multiple levels, from direct drivers to ORMs. Some of the crates are async and some not, which modifies how other code will has to interact with them.

Database drivers and bindings[edit | edit source]

Cargo vec.svgpostgres - includes tokio_postgres for async operations and Postgres pub/sub.

Cargo vec.svgrusqlite - sqlite

Cargo vec.svgmysql

Cargo vec.svgredis

ORMs[edit | edit source]

Cargo vec.svgdiesel is popular, strongly typed ORM. Supports sqlite, Postgres, and mysql.

diesel does not natively support async operations at this time.[1] Cargo vec.svgtokio-diesel and Cargo vec.svgasync-diesel provide async shims that integrate with tokio and async-std runtimes respectively.

Table for SQL types in diesel: https://kotiri.com/2018/01/31/postgresql-diesel-rust-types.html

Other[edit | edit source]

Cargo vec.svgsqlx is a newer crate that supports type checked SQL queries. Fully async and supports Postgres pub/sub.

Connection pooling[edit | edit source]

Cargo vec.svgr2d2

Cargo vec.svgdeadpool

References[edit | edit source]