This is my call: session.query(User.username, User.first_name, User.last_name).all()
It returns: [('myUsername', 'myFirstname', 'myLastname')]
.
I want that to be the following format:[{"username":"myUsername", "first_name":"myFirstname", "last_name":"myLastname"}]
I tried with [dict(zip(["username","first_name","lastname"], x))]
But it returns this: [{'username': ('myUsername', 'myFirstname', 'myLastname')}]
row = session.query(User.username, User.first_name, User.last_name).all()
as_dict = dict(zip(row.keys(), row))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With