如何使用SQLAlchemy在mysql的表或列中添加注释? [英] How to add comments to table or column in mysql using SQLAlchemy?

查看:605
本文介绍了如何使用SQLAlchemy在mysql的表或列中添加注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在表中添加注释,并创建列.

I want to add comments a tabble and columns created.

所以我将doc参数添加到SQLAlchemy Column类的构造函数中.

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.2版中受支持 1.2版中的新功能: http://docs.sqlalchemy.org /en/latest/core/metadata.html#sqlalchemy.schema.Column.params.comment

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

这篇关于如何使用SQLAlchemy在mysql的表或列中添加注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆