felicity-lims/backend/felicity_lims/felicity/utils/psql.py
2021-04-11 10:15:52 +02:00

12 lines
371 B
Python

async def psql_records_to_dict(records, many=False):
"""Converts a db record(s) to dict
database usually return a databases.backends.postgres.Record
or if you access the ._row key you get the asyncpg.Record
"""
if not records:
return records
if not many:
return dict(records)
return [dict(record) for record in records]