Douzero_Resnet/douzero/server/orm.py

53 lines
1.6 KiB
Python
Raw Normal View History

2021-12-25 19:06:34 +08:00
# -*- coding:utf8 -*-
from peewee import *
2021-12-26 12:36:43 +08:00
2021-12-28 16:05:12 +08:00
db = MySQLDatabase(None)
def init_db(flags):
db.init(flags.db_schema, host=flags.db_host, user=flags.db_user, passwd=flags.db_passwd)
Model.create_table()
Battle.create_table()
Baseline.create_table()
2021-12-25 19:06:34 +08:00
class BaseModel(Model):
class Meta:
database = db
class Model(BaseModel):
path = CharField(primary_key=True)
position = CharField(null = False)
type = CharField(null = False)
frame = IntegerField(null = False)
create_time = DateTimeField(null=False)
class Meta:
order_by = ('type',)
db_table = 'model'
class Battle(BaseModel):
id = PrimaryKeyField()
2021-12-27 11:22:49 +08:00
challenger_path = CharField(null = False, index = True)
2021-12-25 19:06:34 +08:00
challenger_position = CharField(null = False)
2021-12-27 11:22:49 +08:00
status = IntegerField(null = False, index = True)
2021-12-25 19:06:34 +08:00
challenger_wp = DecimalField(null=True)
challenger_adp = DecimalField(null=True)
class Meta:
order_by = ('id',)
db_table = 'battle'
class Baseline(BaseModel):
id = PrimaryKeyField()
landlord_path = ForeignKeyField(Model, to_field='path',related_name = "model")
landlord_up_path = ForeignKeyField(Model, to_field='path',related_name = "model")
landlord_front_path = ForeignKeyField(Model, to_field='path',related_name = "model")
landlord_down_path = ForeignKeyField(Model, to_field='path',related_name = "model")
2021-12-27 11:22:49 +08:00
rank = IntegerField(null = False, index = True)
2021-12-25 19:06:34 +08:00
landlord_wp = DecimalField(null=False)
farmer_wp = DecimalField(null=False)
landlord_adp = DecimalField(null=False)
farmer_adp = DecimalField(null=False)
create_time = DateTimeField(null=False)
class Meta:
order_by = ('id',)
db_table = 'baseline'