-
Notifications
You must be signed in to change notification settings - Fork 106
/
city.py
executable file
·30 lines (27 loc) · 913 Bytes
/
city.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
#!/usr/bin/python3
""" holds class City"""
import models
from models.base_model import BaseModel, Base
from os import getenv
import sqlalchemy
from sqlalchemy import Column, String
from sqlalchemy.orm import relationship
from sqlalchemy import ForeignKey
class City(BaseModel, Base):
"""Representation of city """
if getenv('HBNB_TYPE_STORAGE') == 'db':
__tablename__ = 'cities'
name = Column(String(128),
nullable=False)
state_id = Column(String(60),
ForeignKey('states.id'),
nullable=False)
places = relationship("Place",
backref="cities",
cascade="all, delete-orphan")
else:
name = ""
state_id = ""
def __init__(self, *args, **kwargs):
"""initializes city"""
super().__init__(*args, **kwargs)