54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
# -*- coding:utf8 -*-
|
|
from peewee import *
|
|
|
|
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()
|
|
|
|
|
|
class BaseModel(Model):
|
|
class Meta:
|
|
database = db
|
|
|
|
class Model(BaseModel):
|
|
path = CharField(primary_key=True, max_length=255)
|
|
position = CharField(null = False, max_length=32)
|
|
type = CharField(null = False, max_length=32)
|
|
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, max_length=255, index = True)
|
|
challenger_position = CharField(null = False, max_length=32)
|
|
opponent_rank = IntegerField(null = False, index = True)
|
|
status = IntegerField(null = False, index = True)
|
|
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, index = True)
|
|
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'
|