-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
37 lines (27 loc) · 947 Bytes
/
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
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.exc import OperationalError
from sqlalchemy.orm import Session
__all__=["PrivateBoards", "GroupBoards", "session"]
Base = declarative_base()
class PrivateBoards(Base):
__tablename__ = 'privateboards'
id = Column(Integer, primary_key = True)
user_name = Column(String)
board = Column(String)
games = Column(Integer, default = 0)
win=Column(Integer, default = 0)
lose = Column(Integer, default = 0)
tie = Column(Integer, default = 0)
class GroupBoards(Base):
__tablename__ = "groupboards"
id = Column(String, primary_key=True)
player1 = Column(String)
player2 = Column(String)
board = Column(String)
engine = create_engine('sqlite:///data.db')
try:
Base.metadata.create_all(engine)
except OperationalError:
pass
session=Session(engine)