问题
I want to add comments a tabble and columns created.
so I add doc parameter to the constructor of SQLAlchemy Column class.
But do not add comments the column.
class Notice(db.Model):
__tablename__ = "tb_notice"
__table_args__ = {'mysql_engine': 'MyISAM'}
seqno = db.Column(db.Integer, primary_key=True, autoincrement=True, doc="seqno")
title = db.Column(db.String(200), nullable=False, doc="notice title")
detail = db.Column(db.TEXT, nullable=True, doc="notice detail ")
And I wonder how to add the comment of table.
回答1:
comment only supported in version 1.2 New in version 1.2: http://docs.sqlalchemy.org/en/latest/core/metadata.html#sqlalchemy.schema.Column.params.comment
回答2:
in new 1.2 version you can do
class Notice(db.Model):
__tablename__ = "tb_notice"
__table_args__ = {
'mysql_engine': 'MyISAM'
'comment': 'yeah comment'
}
来源:https://stackoverflow.com/questions/38709800/how-to-add-comments-to-table-or-column-in-mysql-using-sqlalchemy