forked from epfahl/graphene_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
33 lines (25 loc) · 823 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
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import orm
from sqlalchemy import (
Column,
Integer,
String,
ForeignKey)
Base = declarative_base()
class Account(Base):
__tablename__ = 'accounts'
id = Column(Integer, primary_key=True)
name = Column(String)
locations = orm.relationship('Location', backref='account')
users = orm.relationship('User', backref='account')
class Location(Base):
__tablename__ = 'locations'
id = Column(Integer, primary_key=True)
account_id = Column(Integer, ForeignKey('accounts.id'))
name = Column(String)
address = Column(String)
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
account_id = Column(Integer, ForeignKey('accounts.id'))
name = Column(String)