userName = CharField(null=False) belongPart = IntegerField(null=False) classifyName = CharField(null=False) createDate = DateTimeField(null=False) articleNum = IntegerField(null=False) class Meta: db_table = 'blog_classify' class blogArticle(MyBaseModel): articleName = CharField(null=False) articleAuthor = CharField(null=False) articleIntroduce = TextField(null=False) articlePart = IntegerField(null=False) articleEditorTime = DateTimeField(null=False) articleClassify = CharField(null=False) articleReadRole = IntegerField(null=False) #1表所有人,0表自己 articleState = IntegerField(null=False) #0表示未完成,1表示完成 articleBody = TextField(null=True) articleReadTimes = IntegerField(null=False) articleUrl = CharField(null=False) class Meta: db_table = 'blog_article' # primary_key=True # max_date = stu_transaction_record.select(stu_transaction_record.tradingTime).where(stu_transaction_record.stuID == stu_id).aggregate(fn.Max(stu_transaction_record.tradingTime)) db.create_tables([blogUser, blogArticle, blogClassify], safe=True)
# -*-coding:utf-8 -*- from peewee import Model, CharField from playhouse.pool import PooledMySQLDatabase mysql_db = PooledMySQLDatabase("tornado_auth", user='******', password='******', host='127.0.0.1', port=3306, max_connections=20, stale_timeout=300) class AuthenticationModel(Model): class Meta: database = mysql_db class User(AuthenticationModel): username = CharField(unique=True, null=False) password = CharField(null=False) salt = CharField() mysql_db.connect() mysql_db.create_tables([ User, ], safe=True)
db_table = 'stu_sleep_count' primary_key = False class stu_score_count(MyBaseModel): stuID = CharField(null=True) scoreCountInfo = TextField(null=True) lastTimeCountDate = CharField(null=True) class Meta: db_table = 'stu_score_count' primary_key = False class stu_some_state(MyBaseModel): stuID = CharField(null=False, primary_key=True) lastTimeCountDate = CharField(null=True) earlyWarningInfo = TextField(null=True) vacationStayflag = CharField(null=True) stayDate = TextField(null=True) stayRemarks = CharField(null=True) warningHistory = TextField(null=True) scoreWarningLevel = IntegerField(null=True) db.create_tables([ stu_some_state, exam_results, stu_focus, stu_cost_count, stu_score_count, stu_sleep_count ], safe=True)