Skip to content

sqlx::FromRow to map row result of tokio-postgres #764

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

Closed
shiftrtech opened this issue Oct 25, 2020 · 3 comments
Closed

sqlx::FromRow to map row result of tokio-postgres #764

shiftrtech opened this issue Oct 25, 2020 · 3 comments
Labels
question Further information is requested waiting for author

Comments

@shiftrtech
Copy link

Hi, i am new to rust, i am using SQLX to manage my database connection, but i want to use tokio-postgres and map the row result with the types from SQLX its that posible?, thanks.

@abonander
Copy link
Collaborator

The question doesn't really make sense because SQLx and tokio-postgres are competing solutions. What do you need that tokio-postgres does but SQLx doesn't?

@abonander abonander added waiting for author question Further information is requested labels Oct 27, 2020
@shiftrtech
Copy link
Author

Hi, firstly nice library, i need to make something like this, also i need to make this or this.

In general terms i need to make a import data tool for a postgres backend, thanks.

@abonander
Copy link
Collaborator

You can execute plain query strings (including multiple statements separated by semicolons) by importing the Executor trait and then calling the relevant methods directly on a connection:

use sqlx::Executor;

    let mut conn: PgConnection = ...;
    conn.execute("insert into foo(...) ...; update foo set bar = true where id > 1").await?;

    // same as `sqlx::query(...).fetch(&mut conn)`
    let mut results = conn.fetch("select id, bar from foo");

The downside here is that you cannot use bind parameters with these queries.

Postgres COPY support is being discussed in #36 and I have a branch that mostly just needs to be rebased and tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested waiting for author
Projects
None yet
Development

No branches or pull requests

2 participants