from sqlalchemy.sql.expression import null from db_connector import database from sqlalchemy import Integer, Column, Float, VARCHAR, ForeignKey #NOTE: Taumata longest place name on earth, 85 characters, # also accounting for the extended ASCII characters, # varchar of 200 Bytes should be sufficient for every use # case even with multiword names such as "The Big Apple" class Location(database): """ Location model representing a physical location on Earth. Attributes: id (int): The unique identifier for each location. name (str): The name of the location. country (str): The country where the location is located. latitude (float): The latitude coordinate of the location. longitude (float): The longitude coordinate of the location. """ __tablename__='locations' id=Column(Integer,primary_key=True) name=Column(VARCHAR(200),nullable=False) country=Column(VARCHAR(100),nullable=False) latitude=Column(Float,nullable=False) longitude=Column(Float,nullable=False) def __repr__(self): return "id={} name={} longitude={} latitude={}".format(self.id,self.name,self.longitude,self.latitude) class Users(database): """ Users model representing a registered user of the application. Attributes: id (int): The unique identifier for each user. name (str): The name of the user. email (str): The email address of the user. """ __tablename__='users' id=Column(Integer,primary_key=True, autoincrement=True) name=Column(VARCHAR(200),nullable=False) email=Column(VARCHAR(100),nullable=False) def __repr__(self): return "id={} name={}".format(self.id,self.name) class Config(database): """ Config model representing a configuration for a user and location pair. Attributes: id (int): The unique identifier for each configuration. user_id (int): The foreign key referencing the Users table. location_id (int): The foreign key referencing the Locations table. """ __tablename__='config' id=Column(Integer,primary_key=True, autoincrement=True) user_id=Column(Integer,ForeignKey(Users.id)) location_id=Column(Integer,ForeignKey(Location.id)) def __repr__(self): return "id={} user_id={} location_id={}".format(self.id,self.user_id,self.location_id)