关于python:peewee-定义-createdat-和-updatedat

46次阅读

共计 478 个字符,预计需要花费 2 分钟才能阅读完成。

class SearchEngineCheck(Model):
    category = CharField()
    track_source_id = IntegerField()
    keyword = CharField()
    clip_len = IntegerField(null=True)
    has_error = BooleanField(default=False)
    created_at = DateTimeField(
        null=False,
        constraints=[SQL('DEFAULT CURRENT_TIMESTAMP')],
        help_text='应用数据库工夫'
    )
    updated_at = DateTimeField(
        null=False,
        constraints=[SQL('DEFAULT CURRENT_TIMESTAMP'),
            SQL('ON UPDATE CURRENT_TIMESTAMP'),
        ]
    )

    class Meta:
        database = db
        table_name = 'parse_monitoring'
        indexes = (('parsed_at', 'track_source_id'),
        )

正文完
 0