Skip to content

How to stream a query from sqlx using axum #400

Answered by davidpdrsn
apps4uco asked this question in Q&A
Discussion options

You must be logged in to vote

If sqlx's streams borrow the connection (or connection pool) then its not compatible with axum's StreamBody since it requires a 'static stream, meaning it must be fully owned and not contain borrows.

You're also trying to stream sql rows which you cannot stream as raw HTTP bodies (unless sqlx's streams are already of Vec<u8>s). You can only stream something that can be converted into Bytes. This is also shown in the trait bounds of StreamBody::new.

I'm not familiar enough with sqlx to know how to make it work (or if its even possible). I think you'll get better help asking them.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@apps4uco
Comment options

@davidpdrsn
Comment options

Answer selected by davidpdrsn
Comment options

You must be logged in to vote
1 reply
@cbeck88
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants