I have this set of code which queries the db.
get_user_details = (
self.db_session.query(
users_table.firstname,
users_table.lastname,
users_table.profile_pic,
users_table.email,
)
.filter(users_table.userid == user_payload["userid"])
.first()
)
when I print get_user_details
I am getting a tuple with values. But I need a to get a JSON output with key
and value
pair. key
as the column
name.
How can I achieve this?
Currently I am using
def alchemyencoder(obj):
"""JSON encoder function for SQLAlchemy special classes."""
if isinstance(obj, datetime.date):
return obj.isoformat()
elif isinstance(obj, decimal.Decimal):
return float(obj)
elif isinstance(obj, datetime.time):
return obj.strftime("%H:%M")
to serialize the code.