Skip to content

Library usage with sqlx::postgres::PgConnection #22

Open
@onx2

Description

@onx2

I was wondering if it was possible to use this in a bin file with sqlx's postgres PgConnection? I'm getting and error with my current implementation.

I'm trying to create a script that will create my database, run movine init and movine fix, then seed the database with mock data.

fn main() -> Result<()> {
    dotenv().ok();
    let database_url = dotenv::var("DATABASE_URL").expect("Missing database_url.");

    let pg_conn = block_on(init_database(&database_url))?;
    // this is what is returned
    // sqlx::postgres::PgConnection::connect(&database_url).await?

    let mut movine = Movine::new(&mut pg_conn);
    movine.init()?;
    movine.fix()?;
    // Seed DB

    Ok(())
}
the trait bound `PgConnection: DbAdaptor` is not satisfied
required because of the requirements on the impl of `DbAdaptor` for `&mut PgConnection`
required by `Movine::<T>::new`rustcE0277
let pg_conn: PgConnection
Go to PgConnection

BTW this is an awesome crate, great work 😃 It has been so easy using it so far!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions