-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmodels.py
More file actions
29 lines (21 loc) · 763 Bytes
/
Copy pathmodels.py
File metadata and controls
29 lines (21 loc) · 763 Bytes
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
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from config import url
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
user_id = Column(Integer, primary_key=True)
msg_count = Column(Integer)
ro_level = Column(Integer)
def __init__(self, user_id):
self.user_id = user_id
self.msg_count = 0
self.ro_level = 0
def __repr__(self):
return "User ID: {0}\nMessage count: {1}\nRO level: {2}\n". \
format(self.user_id, self.msg_count, self.ro_level)
engine = create_engine(url)
Base.metadata.create_all(bind=engine)
Session = sessionmaker(bind=engine)