#orm #database #sql


An async extension for Diesel the safe, extensible ORM and Query Builder

2 releases

0.1.1 Oct 19, 2022
0.1.0 Sep 27, 2022

#977 in Database interfaces

Download history 75/week @ 2022-09-23 186/week @ 2022-09-30 228/week @ 2022-10-07 189/week @ 2022-10-14 329/week @ 2022-10-21 312/week @ 2022-10-28 389/week @ 2022-11-04 581/week @ 2022-11-11 716/week @ 2022-11-18 238/week @ 2022-11-25

1,968 downloads per month


2.5K SLoC

A async interface for diesel

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."

Diesel-async provides an async implementation of diesels connection implementation and any method that may issue an query. It is designed as pure async drop in replacement for the corresponding diesel methods.

Supported databases:

  1. PostgreSQL
  2. MySQL


Licensed under AGPL v3 or later Feel free to reach out if you require a more permissive licence.


Diesel-async provides async variants of diesel related query functionality

diesel-async is an extension to diesel itself. It is designed to be used together with the main diesel crate. It only provides async variants of core diesel traits, that perform actual io-work. This includes async counterparts the following traits:

These traits closely mirror their diesel counter parts while providing async functionality.

In addition to these core traits 2 fully async connection implementations are provided by diesel-async:

  • [AsyncMysqlConnection] (enabled by the mysql feature)
  • [AsyncPgConnection] (enabled by the postgres feature)

Ordinary usage of diesel-async assumes that you just replace the corresponding sync trait method calls and connections with their async counterparts.

# include!("./doctest_setup.rs");
use diesel::prelude::*;
use diesel_async::{RunQueryDsl, AsyncConnection};

diesel::table! {
   users(id) {
       id -> Integer,
       name -> Text,
# #[tokio::main(flavor = "current_thread")]
# async fn main() {
#     run_test().await;
# }
# async fn run_test() -> QueryResult<()> {

use crate::users::dsl::*;

# let mut connection = establish_connection().await;
# /*
let mut connection = AsyncPgConnection::establish(std::env::var("DATABASE_URL")?).await?;
# */
let data = users
    // use ordinary diesel query dsl here
    // execute the query via the provided
    // async variant of `diesel_async::RunQueryDsl`
    .load::<(i32, String)>(&mut connection)
let expected_data = vec![
    (1, String::from("Sean")),
    (2, String::from("Tess")),
assert_eq!(expected_data, data);
#     Ok(())
# }


~205K SLoC