0

I want to connect to my database with Postgres in rocket app. But PgConnection doesn't impl trait Fairling: 'error[E0599]: no function or associated item named fairlingfound for struct`MyDatabase in the current scope'

my Cargo.toml

[package]
name = "db_testing"
version = "0.1.0"
edition = "2021"

[dependencies]
rocket = { version = "0.5.0-rc.1", features = ["json"] }
diesel = { version = "2.0.0", features = ["chrono", "r2d2", "uuid", "postgres"] }
diesel_migrations = "2.0.0"

[dependencies.rocket_contrib]
version = "0.4.11"
default-features = false
features = ["diesel_postgres_pool"]

[dependencies.rocket_sync_db_pools]
version = "0.1.0-rc.2"
features = ["diesel_postgres_pool"]

my main.rs

#[macro_use] extern crate rocket;

use rocket_sync_db_pools::{database, diesel};

#[database("time-board")]
struct MyDatabase(diesel::PgConnection);

#[launch]
fn rocket() -> _ {
    rocket::build()
        .attach(MyDatabase::fairling())
}

my Rocket.toml

[default.databases.time-board]
url = "postgres://postgres:example@localhost/time-board"

I tried to do the same thing as there(https://api.rocket.rs/master/rocket_sync_db_pools/index.html#configuration) there's diesel_postgres_pool feature for diesel::PgConnection but it doesn`t work

  • This is a duplicate of https://stackoverflow.com/questions/73806029/rust-rocket-diesel-how-can-i-query-a-mysqldatabase-using-rocket-sync-db-pools – weiznich Jan 18 '23 at 19:49

0 Answers0