Skip to content

How to use uuid with sqlite? #1683

Answered by dvob
woile asked this question in Q&A
Feb 6, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

@woile query_as returns a String if you used TEXT and Vec<u8> if you used BLOB. To convert it to a Uuid you have to use the SELECT uuid as "uuid: uuid::Uuid" FROM ... syntax.
Here you can find an example: https://github.com/dvob/sqlx-test/blob/1da9e0bde140c247f862c0079c74ed30d6fa1919/src/user.rs#L55
Here is the documentation: https://docs.rs/sqlx/latest/sqlx/macro.query_as.html#column-type-override-infer-from-struct-field

Replies: 1 comment 1 reply

Comment options

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

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