mirror of
https://github.com/beak-insights/felicity-lims.git
synced 2025-02-23 16:33:11 +08:00
10 lines
365 B
Python
10 lines
365 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]
|