Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
onx2 opened this issue Sep 12, 2021 · 1 comment
Open

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

onx2 opened this issue Sep 12, 2021 · 1 comment

Comments

@onx2
Copy link

onx2 commented Sep 12, 2021

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!

@byronwasti
Copy link
Owner

Right now Movine won't work with sqlx until the adapter trait is applied to it. It will look very similar to the current Postgres connection except with sqlx as the connection provider (https://github.com/byronwasti/movine/blob/master/src/adaptor/postgres.rs)

I'm a bit swamped, but happy to review a PR if you want to add it. It might be necessary to add feature gates for it if the types conflict (which is something I need to add regardless).

Glad you've enjoyed the crate so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants