What ORM do you use?

This page summarizes the projects mentioned and recommended in the original post on /r/rust

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • prisma-client-rust

    Type-safe database access for Rust

  • Prisma Client Rust. If you come from the JS/TS world this fits right in. It's halfway between a full ORM and SQL(x), so I prefer it.

  • metrics

  • No it will likely not be less performant. See these numbers for some benchmark results for numbers. (As always with benchmarks: Please don't trust my numbers. To be sure you need to do your own benchmarks with your own use-case)

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • cornucopia

    Generate type-checked Rust from your PostgreSQL.

  • I like Cornucopia. It’s a SQL-first approach, so I don’t have to worry about an ORM generating pathological queries. It’s also basically zero cost compared to directly using rust-postgres and supports both sync and async. I also like that my SQL queries end up separate from my Rust code, so it’s easy to update all the relevant queries when the schema changes.

  • thorn

    Experimental PostgreSQL query builder (by Lantern-chat)

  • None. I find ORMs to be too restrictive when I really need to get in and optimize my queries. I wrote my own custom query builder which allows me to use mixed SQL/Rust syntax for complex dynamic queries.

  • sqlx

    🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite. (by launchbadge)

  • however, a much worse problem is its inability to do dynamic queries. If you have two queries that only differ in a column name, you're forced to copy paste the entire query. You can try and hack around it, but it's ugly either way. Here's a good overview, with no really good solutions.

  • diesel

    A safe, extensible ORM and Query Builder for Rust

  • some things are barely expressible in the type system. For example, window functions are unavailable (the issue is six years old). You can use raw SQL, but then it has the same problems sqlx has

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts