-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodels.py
65 lines (51 loc) · 1.94 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Column, String, Integer, ForeignKey, Boolean, DateTime
db = SQLAlchemy()
'''
setup_db(app)
binds a flask application and a SQLAlchemy service
'''
def setup_db(app):
app.config["SQLALCHEMY_DATABASE_URI"] = app.config.get('DATABASE_URI')
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db.app = app
db.init_app(app)
db.create_all()
#----------------------------------------------------------------------------#
# Models.
#----------------------------------------------------------------------------#
class Venue(db.Model):
__tablename__ = 'Venue'
id = Column(Integer, primary_key=True)
name = Column(String(120))
genres = Column(String(120))
address = Column(String(120))
city = Column(String(120))
state = Column(String(120))
phone = Column(String(120))
website = Column(String(500))
facebook_link = Column(String(120))
seeking_talent = Column(Boolean, default=False)
seeking_description = Column(String(500))
image_link = Column(String(500))
shows = db.relationship('Show', backref='Venue', lazy='dynamic')
class Artist(db.Model):
__tablename__ = 'Artist'
id = Column(Integer, primary_key=True)
name = Column(String(120))
genres = Column(String(120))
city = Column(String(120))
state = Column(String(120))
phone = Column(String(120))
website = Column(String(500))
facebook_link = Column(String(120))
seeking_venue = Column(Boolean, default=False)
seeking_description = Column(String(500))
image_link = Column(String(500))
shows = db.relationship('Show', backref='Artist', lazy='dynamic')
class Show(db.Model):
__tablename__ = 'Show'
id = Column(Integer, primary_key=True)
venue_id = Column(Integer, ForeignKey('Venue.id'), nullable=False)
artist_id = Column(Integer, ForeignKey('Artist.id'), nullable=False)
start_time = Column(DateTime(timezone=True))