kenken999's picture
fda
0f43f8a
raw
history blame
1.06 kB
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
username = Column(String, unique=True)
password = Column(String)
profile = Column(String)
team_id = Column(Integer, ForeignKey('teams.id'))
team = relationship('Team', backref='users')
class Team(Base):
__tablename__ = 'teams'
id = Column(Integer, primary_key=True)
name = Column(String, unique=True)
created_at = Column(DateTime, default=datetime.utcnow)
class Profile(Base):
__tablename__ = 'profiles'
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('users.id'))
user = relationship('User', backref='profile')
profile = Column(String)
tags = Column(String)
engine = create_engine('sqlite:///database.db')
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()