mirror of
https://github.com/stijndcl/didier.git
synced 2026-06-29 17:39:57 +02:00
Command stats
This commit is contained in:
parent
ce9ecc8c61
commit
41f75d7bbd
4 changed files with 47 additions and 45 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from database import all_models, engine
|
||||
from database import all_models, engine, Base
|
||||
from typing import Dict
|
||||
|
||||
|
||||
def create_all_tables():
|
||||
|
|
@ -9,3 +10,16 @@ def create_all_tables():
|
|||
"""
|
||||
for model in all_models:
|
||||
model.__table__.create(engine, checkfirst=True)
|
||||
|
||||
|
||||
def row_to_dict(row: Base) -> Dict:
|
||||
"""
|
||||
Create a dictionary from a database entry
|
||||
vars() or dict() can NOT be used as these add extra SQLAlchemy-related properties!
|
||||
"""
|
||||
d = {}
|
||||
|
||||
for column in row.__table__.columns:
|
||||
d[column.name] = getattr(row, column.name)
|
||||
|
||||
return d
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue