-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.py
43 lines (38 loc) · 1.5 KB
/
model.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
37
38
39
40
41
42
43
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relation
from sqlalchemy.sql import func
Base = declarative_base()
class Organization(Base):
__tablename__ = "organization"
id = Column(Integer, primary_key=True)
name = Column(String(64))
class User(Base):
__tablename__ = "user"
id = Column(Integer, primary_key=True)
FirstName = Column(String(64))
LastName = Column(String(64))
NRC = Column(String(64))
DOB = Column(String(64))
nationality = Column(String(64))
location = Column(String(64))
organization = relation('Organization', backref='user')
Organization_id = Column(Integer, ForeignKey('organization.id'))
class Client(Base):
__tablename__ = 'client'
id = Column(Integer, primary_key=True)
name = Column(String(64))
location = Column(String(64))
number_cameras = Column(Integer)
user = relation('User', backref='client')
user_id = Column(Integer, ForeignKey('user.id'))
organization = relation('Organization', backref='client')
Organization_id = Column(Integer, ForeignKey('organization.id'))
class Cameras(Base):
__tablename__ = 'camera'
id = Column(Integer, primary_key=True)
Location = Column(String(64))
Model = Column(String(64))
Date_installed = Column(DateTime, server_default=func.now())
Client_id = Column(Integer, ForeignKey('client.id'))
client = relation('Client', backref='camera')