TelegramAktienBot/webservice/models.py
2022-03-13 21:23:41 +01:00

35 lines
1.5 KiB
Python

from db import db
class User(db.Model):
__tablename__ = 'users'
username = db.Column('username', db.String(255), nullable=False, unique=True, primary_key=True)
password = db.Column('password', db.String(255), nullable=False, server_default='')
user_id = db.Column('user_id', db.Integer())
telegram_name = db.Column('telegram_name', db.String(255), nullable=True, server_default='')
admin = db.Column('admin', db.Boolean(), server_default='0')
class Transaction(db.Model):
__tablename__ = 'transactions'
t_id = db.Column('t_id', db.Integer(), nullable=False, unique=True, primary_key=True)
user_id = db.Column('user_id', db.Integer(), db.ForeignKey('users.user_id', ondelete='CASCADE'))
symbol = db.Column('symbol', db.String(255))
time = db.Column('time', db.DateTime())
count = db.Column('count', db.Integer())
price = db.Column('price', db.Float())
class Keyword(db.Model):
__tablename__ = 'keywords'
s_id = db.Column('s_id', db.Integer(), nullable=False, unique=True, primary_key=True)
user_id = db.Column('user_id', db.Integer(), db.ForeignKey('users.user_id', ondelete='CASCADE'))
keyword = db.Column('keyword', db.String(255))
class Share(db.Model):
__tablename__ = 'shares'
a_id = db.Column('a_id', db.Integer(), nullable=False, unique=True, primary_key=True)
user_id = db.Column('user_id', db.Integer(), db.ForeignKey('users.user_id', ondelete='CASCADE'))
symbol = db.Column('symbol', db.String(255))