diesel-rs/diesel — 14.2k★ on GitHub (Rust). A safe, extensible ORM and Query Builder for Rust
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Diesel gets rid of the boilerplate for database interaction and eliminates
runtime errors without sacrificing performance. It takes full advantage of
Rust's type system to create a low overhead query builder that "feels like
Rust."
Supported databases:
PostgreSQL
MySQL
SQLite
MariaDB
You can configure the database backend in Cargo.toml:
[dependencies]
diesel = { version = "<version>", features = ["<postgres|mysql|sqlite>"] }
Getting Started
Find our extensive Getting Started tutorial at
https://diesel.rs/guides/getting-started.
Guides on more specific features are coming soon.
Getting help
If you run into problems, you can come ask for help at in our GitHub Discussions forum.
This is also the right place to propose new features or show your applications.
Usage
Simple queries
Simple queries are a complete breeze. Loading all users from a database:
users::table.load(&mut connection)
Executed SQL:
SELECT * FROM users;
Loading all the posts for a user:
Post::belonging_to(user).load(&mut connection)
Executed SQL:
SELECT * FROM posts WHERE user_id = 1;
Complex queries
Diesel's powerful query builder helps you construct queries as simple or complex as
you need, at zero cost.
let versions = Version::belonging_to(krate)
.select(id)
.order(num.desc())
.limit(5);
let downloads = version_downloads
.filter(date.gt(now - 90.days()))
.filter(version_id.eq_any(versions))
.order(date)
.load::<Download>(&mut conn)?;
Executed SQL:
SELECT version_downloads.* FROM version_downloads
WHERE date > (NOW() - '90 days')
AND version_id = ANY(
SELECT id FROM versions
WHERE crate_id = 1
ORDER BY num DESC
LIMIT 5
)
ORDER BY date
Less boilerplate
Diesel codegen generates boilerplate for you. It lets you focus on your business logic, not mapping to and from SQL rows.
There will always be certain queries that are just easier to write as raw SQL, or can't be expressed with the query builder. Even in these cases, Diesel provides an easy to use API for writing raw SQL.
#[derive(QueryableByName)]
#[diesel(table_name = users)]
struct User {
id: i32,
name: String,
organization_id: i32,
}
// Using `include_str!` allows us to keep the SQL in a
// separate file, where our editor can give us SQL specific
// syntax highlighting.
sql_query(include_str!("complex_users_by_organization.sql"))
.bind::<Integer, _>(organization_id)
.bind::<BigInt, _>(offset)
.bind::<BigInt, _>(limit)
.load::<User>(&mut conn)?;
Code of conduct
Anyone who interacts with Diesel in any space, including but not limited to
this GitHub repository, must follow our code of conduct.
License
Licensed under either of these:
Apache License, Version 2.0, (LICENSE-APACHE or
https://www.apache.org/licenses/LICENSE-2.0)
MIT license (LICENSE-MIT or
https://opensource.org/licenses/MIT)
Contributing
Before contributing, please read the contributors guide
for useful information about setting up Diesel locally, coding style and common abbreviations.
Unless you explicitly state otherwise, any contribution you intentionally submit
for inclusion in the work, as defined in the Apache-2.0 license, shall be
dual-licensed as above, without any additional terms or conditions.
Notable Sponsors and Supporters
We would like to thank all of the sponsors supporting the work on Diesel. Notable large sponsors are:
NLNet Foundation
Prototype Fund
GitHub Secure Open Source Fund
NGI Zero Core
Federal Ministry of Research, Technology and Space (Germany)
GiGa Infosystems GmbH
Rust Foundation
Additionally we would like to thank all persons sponsoring the project on GitHub. Without them developing Diesel wouldn't be possible.
The most recent commit recorded on diesel-rs/diesel was 4 months ago, based on the GitHub push timestamp. The repository has 1.3k forks — one of the better signals of community interest.
How many stars does diesel-rs/diesel have?
diesel-rs/diesel has 14.2k GitHub stars — refresh the page for the live number, or check github.com/diesel-rs/diesel. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is diesel-rs/diesel open source?
Yes — diesel-rs/diesel ships under the Apache-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/diesel-rs/diesel.
What else is in the Data space?
diesel-rs/diesel is tracked by TopGit under the Data category, alongside 6 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What topics is diesel-rs/diesel associated with?
GitHub's repository topics for diesel-rs/diesel: "mysql", "orm", "postgresql", "query-builder", "rust", "sqlite". TopGit's editorial category is Data.
Where can I see diesel-rs/diesel in action?
The project maintains a homepage at https://diesel.rs. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about diesel-rs/diesel?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/diesel-rs/diesel is the definitive source.
Read full README in the tab above.
Is diesel worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of diesel.