mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
15 lines
310 B
Python
15 lines
310 B
Python
import enum
|
|
|
|
|
|
def row2dict(row):
|
|
""" Generic function to convert a SQLAlchemy row to a dictionary."""
|
|
|
|
d = {}
|
|
for column in row.__table__.columns:
|
|
val = getattr(row, column.name)
|
|
if isinstance(val, enum.Enum):
|
|
val = val.value
|
|
|
|
d[column.name] = val
|
|
|
|
return d
|