Douzero_Resnet/douzero/server/orm.py

50 lines
1.5 KiB
Python
Raw Normal View History

2021-12-25 19:06:34 +08:00
# -*- coding:utf8 -*-
from peewee import *
2021-12-25 22:41:25 +08:00
db = SqliteDatabase('model.db', pragmas={
'journal_mode': 'wal',
'cache_size': -1 * 64000, # 64MB
'foreign_keys': 1,
'ignore_check_constraints': 0,
'synchronous': 0})
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()
challenger_path = CharField(null = False)
challenger_position = CharField(null = False)
status = IntegerField(null = False)
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")
rank = IntegerField(null = False)
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'