Module rocket_db_pools::diesel

source ·
Expand description

Re-export of diesel with prelude types overridden with async variants from diesel_async.


To use async diesel support provided here, enable the following dependencies in your Cargo.toml:

rocket = "0.6.0-dev"
diesel = "2"

version = "0.1.0"
features = ["diesel_mysql"]

Then, import rocket_db_pools::diesel::prelude::* as well as the appropriate pool type and, optionally, QueryResult. To use macros or diesel functions, use diesel:: directly. That is, do not import rocket_db_pools::diesel. Doing so will, by design, cause import errors.


use rocket_db_pools::{Database, Connection};
use rocket_db_pools::diesel::{QueryResult, MysqlPool, prelude::*};

struct Db(MysqlPool);

#[derive(Queryable, Insertable)]
#[diesel(table_name = posts)]
struct Post {
    id: i64,
    title: String,
    published: bool,

diesel::table! {
    posts (id) {
        id -> BigInt,
        title -> Text,
        published -> Bool,

async fn list(mut db: Connection<Db>) -> QueryResult<String> {
    let post_ids: Vec<i64> = posts::table
        .load(&mut db)




  • A connection to a MySQL database. Connection URLs should be in the form mysql://[user[:password]@]host/database_name
  • A connection to a PostgreSQL database.

Type Aliases§