-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_city.py
executable file
·32 lines (27 loc) · 957 Bytes
/
model_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
31
32
#!/usr/bin/python3
"""
Module: model_city.py
Author: TheWatcher01
Date: 21/03/2024
Description:
Python file that contains the class definition of a City.
"""
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class City(Base):
"""
Represents a city for a MySQL database.
Attributes:
id (int): an auto-generated, unique integer
representing the city's ID.
name (str): a string with a maximum of
128 characters representing the city's name.
state_id (int): an integer representing the state's ID
that the city belongs to.
"""
__tablename__ = 'cities'
id = Column(Integer, primary_key=True, nullable=False)
name = Column(String(128), nullable=False)
state_id = Column(Integer, ForeignKey(
'states.id', ondelete="CASCADE"), nullable=False)