Skip to content

How to map query results to objects? #1315

Closed Answered by YuriiMotov
tdoan2010 asked this question in Questions
Discussion options

You must be logged in to vote

Validate results with QueryResult model.
Something like

res = [QueryResult.model_validate({"full_name": row[0], "person_age": row[1]} for row in results)]

Replies: 1 comment 2 replies

Comment options

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

@YuriiMotov
Comment options

Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants