Skip to content
Snippets Groups Projects
Commit 5b67534e authored by y2-youssef's avatar y2-youssef
Browse files

Upload New File

parent 0a1a29f8
Branches
No related tags found
No related merge requests found
from database.connect import connection, base
import sqlalchemy as db
from sqlalchemy.orm import relationship
from datetime import date
class LocationModel(base):
__tablename__ = "location"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(20), nullable=False)
def __init__(self, name: str):
self.name = name
def __repr__(self):
return "<Location %r>" % self.id
class Location:
def __init__(self):
# Get connection to database as session
engine, base, session, meta = connection()
self.session = session
def get_locations(self) -> list:
"""
Get locations from database
Returns:
list: List of all locations
"""
locations = self.session.query(LocationModel).all()
return locations
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment