forked from lakinwecker/ChessReanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
51 lines (40 loc) · 1.28 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from peewee import *
db = SqliteDatabase('./db/data.sqlite3')
class Player(Model):
username = CharField(unique=True)
class Meta:
database = db
class Game(Model):
id = CharField(primary_key=True)
is_analyzed = BooleanField(default=False)
class Meta:
database = db
colors = (('w', 'White'), ('b', 'Black'))
class GamePlayer(Model):
game = ForeignKeyField(Game)
color = FixedCharField(max_length=1, choices=colors)
player = ForeignKeyField(Player)
class Meta:
database = db
indexes = (
(('game', 'color'), True),
)
class Move(Model):
game = ForeignKeyField(Game)
color = FixedCharField(max_length=1, choices=colors)
number = SmallIntegerField()
pv1_eval = SmallIntegerField()
pv2_eval = SmallIntegerField(null=True)
pv3_eval = SmallIntegerField(null=True)
pv4_eval = SmallIntegerField(null=True)
pv5_eval = SmallIntegerField(null=True)
played_eval = SmallIntegerField()
played_rank = SmallIntegerField(null=True)
nodes = IntegerField(null=True)
masterdb_matches = IntegerField(null=True)
class Meta:
database = db
indexes = (
(('game', 'color', 'number'), True),
)
db.create_tables([Player, Game, GamePlayer, Move], True)