sqlx VS diesel

Compare sqlx vs diesel and see what are their differences.

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)

diesel

A safe, extensible ORM and Query Builder for Rust (by diesel-rs)
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
sqlx diesel
148 85
13,134 12,621
2.6% 1.1%
9.5 9.8
11 days ago 4 days ago
Rust Rust
Apache License 2.0 Apache License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

sqlx

Posts with mentions or reviews of sqlx. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-09-08.
  • Sqlc: Compile SQL to type-safe code
    15 projects | news.ycombinator.com | 8 Sep 2024
    This looks like a less ergonomic version of Rust's SQLx (https://github.com/launchbadge/sqlx) but a more robust version of TypeScript's sqlx-ts (https://jasonshin.github.io/sqlx-ts/). Sqlc seems to copy the latter's unfortunate lack of inline SQL statements. Still, seems promising.
  • Build your own SQLite with Rust, Part 1
    1 project | news.ycombinator.com | 17 Aug 2024
    SQLx seems to do some form of this. though what you're suggesting may remove the build time dependency on "connecting" to a SQLite database.

    "SQLx supports compile-time checked queries. It does not, however, do this by providing a Rust API or DSL (domain-specific language) for building queries. Instead, it provides macros that take regular SQL as input and ensure that it is valid for your database. The way this works is that SQLx connects to your development DB at compile time to have the database itself verify (and return some info on) your SQL queries."

    https://github.com/launchbadge/sqlx

  • SQLx: Async, pure Rust SQL crate, compile-time checked queries without a DSL
    1 project | news.ycombinator.com | 22 Jul 2024
  • A tale of TimescaleDB, SQLx and testing in Rust
    1 project | dev.to | 2 May 2024
    For PostgreSQL, the most relevent part of the code is here. With this in mind I changed some things around to rely on schemas instead of databases and even simplified some parts of the implementation as this was always meant to be for internal use only..
  • Rust as a general application language
    2 projects | /r/rust | 9 Dec 2023
    What exactly are you missing? I haven't really written "boring corporate backend stuff" in a few years but something like sqlx provides everything I've ever needed there.
  • Hey Rustaceans! Got a question? Ask here (49/2023)!
    9 projects | /r/rust | 5 Dec 2023
    Badges are the little rectangles you typically see at the top of a crate's README: https://github.com/launchbadge/sqlx/blob/main/README.md
  • A new F# compiler feature: graph-based type-checking
    9 projects | news.ycombinator.com | 5 Nov 2023
    SQLX has entered the chat [1].

    [1] https://github.com/launchbadge/sqlx

  • Grimoire - A recipe management application.
    7 projects | /r/rust | 5 Oct 2023
    Database : SqLite (using sqlx).
  • SQLX MSSQL Connection String Problem
    1 project | /r/rust | 6 Jul 2023
    The current (well, removed) MSSQL sqlx driver also doesn't support encrypted connections (https://github.com/launchbadge/sqlx/issues/1552), so it might work locally on an unnamed instance but not over the network until they add in the newer driver (which will be closed source but for an OSS project you should be able to request a free license I think)
  • Introducing SQLPage : write websites entirely in SQL
    8 projects | /r/rust | 4 Jul 2023
    I'm considering making my own wrapper over lower-level database drivers. There are a lot of features in sqlx that I don't need, and the latest version seems to have removed useful data structures that SQLPage is using. It also removed support for SQL Server.

diesel

Posts with mentions or reviews of diesel. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-09-22.
  • One Year of Rust in Production
    5 projects | news.ycombinator.com | 22 Sep 2024
    > sqlx — a compile time, type safe SQL wrapper that runs your queries against a real DB

    SQLx seems like end game stuff at first glance, but after trying it out for a while I eventually decided that it wasn't for me. Writing dynamic/conditional queries just sucks and there isn't any good solution. On the DX side, completion, formatting/linting, highlighting is also non-existent.

    I eventually settled on [diesel][0] (a query builder-ish ORM) and I'm loving it so far. Its [performance][1] crushes every other SQL libraries, including SQLx (very counter-intuitive, huh?). It's technically an ORM, but the query builder is very flexible and you can also extend it with your own traits. It got its warts, but it's the most tolerable SQL rust library I've found so far.

    [0]: https://diesel.rs

  • Rainfrog – a database management TUI for Postgres
    11 projects | news.ycombinator.com | 16 Sep 2024
    Diesel has support for MySQL, Sqlite and Postgres which can easily execute raw queries

    https://github.com/diesel-rs/diesel

  • Rust in Illumos
    5 projects | news.ycombinator.com | 10 Sep 2024
    Here is another thing worth sharing. Database integration tests on Bazel used to be difficult. Ultimately I've found an elegant solution:

    https://github.com/diesel-rs/diesel/blob/master/examples/pos...

    The parallel testing with dangling transactions isn't Diesel or Postgres specific. You can do the same with pure SQL and any relational DB that supports transactions.

    For CI, BuildBuddy can spin up Docker in a remote execution host, then you write a custom util that tests if the DB container is already running and if not starts one, out that in a test and then let Bazel execute all integration tests in parallel. For some weird reasons, all tests have to be in one file per insolated remote execution host, so I created one per table.

    Incremental builds that compile, tests, build and publish images usually complete in about one minute. That's thanks to the 80 Core BuildBuddy cluster with remote cache.

    GitHub took about an hour back in April when the repo was half in size.

    There is real gain in terms of developer velocity.

  • Top 10 Rusty Repositories for you to start your Open Source Journey
    11 projects | dev.to | 19 Dec 2023
    7. Diesel
  • People who use rust and postgres in production along with RDS proxy, what do you do?
    1 project | /r/rust | 15 Nov 2023
    Both seem nice. However, both of them rely very heavily on prepared statements. Unfortunately, using prepared statements is a no-go when you use connection poolers like pgbouncer, or in my case AWS RDS proxy. A discussion in Diesel indicates that disel is not going to provide any support for disabling prepared stements (https://github.com/diesel-rs/diesel/discussions/3575), and a discussion on sqlx hints that disabling prepared statements is possible, but I haven't found any documentation or examples for it.
  • The diesel project is looking for help
    1 project | /r/rust | 4 Nov 2023
    In addition we are experimenting with prebuild versions of diesel-cli that can be installed directly. We have a set of prebuilt binaries here. We are interested in feedback about how the provided binaries work on your platform.
  • cargo-dist pre-release looking for feedback!
    2 projects | /r/rust | 20 Oct 2023
    First of all thanks for making this great tool. As it happens I currently toy around with using it for diesel-cli releases. See the WIP PR here. I think diesel-cli is a good example of a tool that depends on system libraries as it needs to link native database drivers, so this new release is welcome. Defining the dependencies seems to allow easily building things on x86_64-unknown-linux-gnu and x86_64-apple-darwin. It seems to pick up everything in the right way there.
  • Diesel Is a Safe, Extensible ORM and Query Builder for Rust
    1 project | news.ycombinator.com | 18 Sep 2023
  • Rust & MySQL: connect, execute SQL statements and stored procs using crate sqlx.
    3 projects | dev.to | 11 Sep 2023
    I did look at mysql initially. Then I started checking other crates. Diesel is an Object Relation Model (ORM), I'm not yet keen on taking on the complication of learning ORM, I give this crate a pass in the meantime.
  • Queryx: An Open-Source Go ORM with Automatic Schema Management
    3 projects | /r/golang | 5 Jul 2023
    I would recommend people look at diesel from Rust for how nice it could be. https://diesel.rs/ Look at the complex queries example. So much more readable and easier to understand.

What are some alternatives?

When comparing sqlx and diesel you can also consider the following projects:

sea-orm - 🐚 An async & dynamic ORM for Rust

tokio - A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...

rustorm - an orm for rust

rust-postgres - Native PostgreSQL driver for the Rust programming language

rbatis - Rust Compile Time ORM robustness,async, pure Rust Dynamic SQL

r2d2 - A generic connection pool for Rust

actix-web - Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

prisma-client-rust - Type-safe database access for Rust

sled - the champagne of beta embedded databases

rusqlite-model - Model trait and derive implementation for rusqlite

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured