What ORM do you use?

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

Our great sponsors
  • Revelo Payroll - Free Global Payroll designed for tech teams
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • SonarLint - Clean code begins in your IDE with SonarLint
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • 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)

  • Revelo Payroll

    Free Global Payroll designed for tech teams. Building a great tech team takes more than a paycheck. Zero payroll costs, get AI-driven insights to retain best talent, and delight them with amazing local benefits. 100% free and compliant.

  • 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, SQLite, and MSSQL. (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