添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
class Data(db.Model):
    __tablename__ = "datas"
    id = db.Column(db.Integer, primary_key=True)
    smallInteger = db.Column(db.SmallInteger)
    bigInteger = db.Column(db.BigInteger)
    floatData = db.Column(db.Float(10))
    numericData = db.Column(db.Numeric(10))
    stringData = db.Column(db.String(250))
    textData = db.Column(db.Text(200))
    mediumText = db.Column(db.Text(65536))
    longText = db.Column(db.Text(16777216))
    largeBinary = db.Column(db.LargeBinary(300))
    mediumBlob = db.Column(db.LargeBinary(65536))
    longBlob = db.Column(db.LargeBinary(16777216))
    pickle = db.Column(db.PickleType)
    mediumPickle = db.Column(db.PickleType(65536))
    longPickle = db.Column(db.PickleType(16777216))
    unicodeData = db.Column(db.Unicode(10))
    unicodeText = db.Column(db.UnicodeText)
    booleanData = db.Column(db.Boolean(0))
    dateData = db.Column(db.Date)
    timeData = db.Column(db.Time)
    dateTime = db.Column(db.DateTime)
    interval = db.Column(db.Interval)
    enumData = db.Column(db.Enum('father', 'mother'))
    def __repr__(self):
        return "Data {}".format(self.id)

MySQL表结构

+--------------+-------------------------+------+-----+---------+----------------+
| Field        | Type                    | Null | Key | Default | Extra          |
+--------------+-------------------------+------+-----+---------+----------------+
| id           | int(11)                 | NO   | PRI | NULL    | auto_increment |
| smallInteger | smallint(6)             | YES  |     | NULL    |                |
| bigInteger   | bigint(20)              | YES  |     | NULL    |                |
| floatData     |  float                   | YES  |     | NULL    |                |
| numericData  | decimal(10,0)           | YES  |     | NULL    |                |
| stringData   | varchar(250)            | YES  |     | NULL    |                |
| textData     | tinytext                | YES  |     | NULL    |                |
| mediumText   | mediumtext              | YES  |     | NULL    |                |
| longText     | longtext                | YES  |     | NULL    |                |
| largeBinary  | blob                    | YES  |     | NULL    |                |
| mediumBlob   | mediumblob              | YES  |     | NULL    |                |
| longBlob     | longblob                | YES  |     | NULL    |                |
| pickle       | blob                    | YES  |     | NULL    |                |
| mediumPickle | blob                    | YES  |     | NULL    |                |
| longPickle   | blob                    | YES  |     | NULL    |                |
| unicodeData  | varchar(10)             | YES  |     | NULL    |                |
| unicodeText  | text                    | YES  |     | NULL    |                |
| booleanData  | tinyint(1)              | YES  |     | NULL    |                |
| dateData     | date                    | YES  |     | NULL    |                |
| timeData     | time                    | YES  |     | NULL    |                |
| dateTime     | datetime                | YES  |     | NULL    |                |
| interval     | datetime                | YES  |     | NULL    |                |
| enumData     | enum('father','mother') | YES  |     | NULL    |                |
+--------------+-------------------------+------+-----+---------+----------------+

3 Flask-MySQL键属性

属性描述生效值 primary_key unique 键值唯一性 index nullable default