I need to add descriptive names to columns that will be used as keys for JSON data. I could not find any example or documentation related to that.
from datetime import datetime
from . import db
class MyTable(db.Model):
__tablename__ = "MyTable"
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(255)
created_at = db.Column(db.DateTime)
modified_at = db.Column(db.DateTime)
row=Table.query.first()
for c in row.__table__.columns:
print(c.name)
print(c.description)
There is a description attribute in column but I cannot find, how can I update this. There is no such keyword argument in db.Column method. Is there anyway to update this with some descriptive name and later use it for generating JSON with descriptive keys. There are some other alternatives like doc or defining a mapping dictionary but I want to use this specifically.