class User(UserBase, table=True): __tablename__ = "user" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) hashed_password: Optional[str] = Field( sa_column=Column(Text, nullable=False)) is_active: Optional[bool] = Field(default=False) newsletter: Optional[bool] = Field(default=False) occupation: Optional[str] = Field(sa_column=Column(Text, nullable=True)) domain: Optional[str] = Field(sa_column=Column(Text, nullable=True)) creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))) organization_id: int = Field(sa_column=Column( Integer, ForeignKey("customer.organization.id", ondelete="CASCADE"), nullable=False)) active_study_area_id: int = Field(sa_column=Column( Integer, ForeignKey("basic.study_area.id"), nullable=False)) language_preference: str = Field(sa_column=Column(Text, nullable=False)) organization: "Organization" = Relationship(back_populates="users") roles: List["Role"] = Relationship(back_populates="users", link_model=UserRole) scenarios: List["Scenario"] = Relationship(back_populates="user") study_areas: List["StudyArea"] = Relationship(back_populates="users", link_model=UserStudyArea) data_uploads: List["DataUpload"] = Relationship(back_populates="user") isochrone_calculations: List["IsochroneCalculation"] = Relationship( back_populates="user") user_customizations: List["UserCustomization"] = Relationship( back_populates="users") opportunity_user_configs: List["OpportunityUserConfig"] = Relationship( back_populates="user")
class IsochroneCalculation(SQLModel, table=True): __tablename__ = "isochrone_calculation" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) calculation_type: str = Field(sa_column=Column(Text, nullable=False)) starting_point: str = Field(sa_column=Column(Text, nullable=False)) routing_profile: str = Field(sa_column=Column(Text, nullable=False)) speed: float = Field(sa_column=Column(Float(53), nullable=False)) modus: str = Field(sa_column=Column(Text, nullable=False)) creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))) parent_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.isochrone_calculation.id", ondelete="CASCADE"))) scenario_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"))) user_id: int = Field( sa_column=Column(Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False)) scenario: Optional["Scenario"] = Relationship( back_populates="isochrone_calculations") user: "******" = Relationship(back_populates="isochrone_calculations") isochrone_features: "IsochroneFeature" = Relationship( back_populates="isochrone_calculation")
class DataUpload(SQLModel, table=True): __tablename__ = "data_upload" __table_args__ = {"schema": "customer"} id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True)) data_type: str = Field(sa_column=Column(Text, nullable=False)) upload_type: str = Field(sa_column=Column(Text, nullable=False)) upload_grid_ids: Optional[List[str]] = Field( sa_column=Column(ARRAY(Text()), nullable=False, server_default=text("'{}'::text[]")) ) upload_size: int = Field(nullable=False) creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")) ) user_id: int = Field( sa_column=Column( Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False ) ) study_area_id: int = Field( sa_column=Column( Integer, ForeignKey("basic.study_area.id"), nullable=False ) ) reached_poi_heatmap_computed: Optional[bool] user: "******" = Relationship(back_populates="data_uploads") study_area: "StudyArea" = Relationship(back_populates="data_uploads") pois_user: List["PoiUser"] = Relationship(back_populates="data_upload") aois_user: List["AoiUser"] = Relationship(back_populates="data_upload")
class UserCustomization(SQLModel, table=True): __tablename__ = "user_customization" __table_args__ = {"schema": "customer"} id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True)) setting: dict = Field(sa_column=Column(JSONB, nullable=False)) creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")) ) user_id: int = Field( sa_column=Column( Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False ) ) customization_id: int = Field( sa_column=Column( Integer, ForeignKey("customer.customization.id", ondelete="CASCADE"), nullable=False ) ) study_area_id: int = Field( sa_column=Column( Integer, ForeignKey("basic.study_area.id"), nullable=False ) ) customizations: "Customization" = Relationship(back_populates="user_customizations") users: "User" = Relationship(back_populates="user_customizations") study_areas: "StudyArea" = Relationship(back_populates="user_customizations")
class Scenario(SQLModel, table=True): __tablename__ = "scenario" __table_args__ = {"schema": "customer"} id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True)) scenario_name: str = Field(sa_column=Column(Text, nullable=False)) routing_heatmap_computed: Optional[bool] creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")) ) user_id: int = Field( sa_column=Column( Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False ), ) data_upload_ids: Optional[List[int]] = Field( sa_column=Column(ARRAY(Integer()), server_default=text("'{}'::int[]")) ) study_area_id: int = Field( sa_column=Column(Integer, ForeignKey("basic.study_area.id"), nullable=False) ) user: "******" = Relationship(back_populates="scenarios") isochrone_calculations: List["IsochroneCalculation"] = Relationship(back_populates="scenario") pois_modified: List["PoiModified"] = Relationship(back_populates="scenario") aois_modified: List["AoiModified"] = Relationship(back_populates="scenario") populations_modified: List["PopulationModified"] = Relationship(back_populates="scenario") buildings_modified: List["BuildingModified"] = Relationship(back_populates="scenario") edges: List["Edge"] = Relationship(back_populates="scenario") ways_modified: List["WayModified"] = Relationship(back_populates="scenario") nodes: List["Node"] = Relationship(back_populates="scenario")
class BuildingModified(BuildingBase, table=True): __tablename__ = "building_modified" __table_args__ = {"schema": "customer"} creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")) ) building_id: Optional[int] = Field( sa_column=Column( Integer, ForeignKey("basic.building.id", ondelete="CASCADE"), default=None ), ) scenario_id: int = Field( sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True, nullable=False, ), ) population: Optional[float] = Field(sa_column=Column(Float(53))) building: Optional["Building"] = Relationship(back_populates="buildings_modified") scenario: "Scenario" = Relationship(back_populates="buildings_modified") populations_modified: Optional[List["PopulationModified"]] = Relationship( back_populates="building_modified" ) edit_type: str = Field(sa_column=Column(Text, nullable=False, index=True)) outdated: Optional[bool] = Field(sa_column=Column(Boolean, default=False))
class UserRole(SQLModel, table=True): __tablename__ = "user_role" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) user_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.user.id"), nullable=False, index=True)) role_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.role.id"), nullable=False, index=True))
class OpportunityStudyAreaConfig(OpportunityConfigBase, table=True): __tablename__ = "opportunity_study_area_config" __table_args__ = {"schema": "basic"} opportunity_group_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("basic.opportunity_group.id"), nullable=False)) study_area_id: int = Field(sa_column=Column( Integer, ForeignKey("basic.study_area.id"), nullable=False)) is_active: bool = Field(sa_column=Column(Boolean, nullable=False)) study_area: "StudyArea" = Relationship( back_populates="opportunity_study_area_configs") opportunity_group: "OpportunityGroup" = Relationship( back_populates="opportunity_study_area_configs")
class StudyAreaGridVisualization(SQLModel, table=True): __tablename__ = "study_area_grid_visualization" __table_args__ = {"schema": "basic"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) study_area_id: int = Field(sa_column=Column( Integer, ForeignKey( "basic.study_area.id"), nullable=False, index=True)) grid_visualization_id: int = Field(sa_column=Column( BigInteger, ForeignKey("basic.grid_visualization.id"), nullable=False, ))
class LayerLibrary(SQLModel, table=True): __tablename__ = "layer_library" __table_args__ = {"schema": "customer"} id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True)) name: str = Field(sa_column=Column(Text(), nullable=False, index=True)) url: Optional[str] = Field(sa_column=Column(Text)) legend_urls: List[str] = Field( sa_column=Column(ARRAY(Text())) ) special_attribute: Optional[dict] = Field(sa_column=Column(JSONB)) access_token: Optional[str] = Field(sa_column=Column(Text)) type: str = Field(sa_column=Column(Text(), nullable=False, index=True)) map_attribution: Optional[str] = Field(sa_column=Column(Text)) date: Optional[datetime] = Field( sa_column=Column(Text) ) source: Optional[str] = Field( sa_column=Column( Text, ForeignKey("customer.layer_source.name", onupdate="CASCADE"), nullable=True, ) ) date_1: Optional[datetime] = Field( sa_column=Column(Text) ) source_1: Optional[str] = Field( sa_column=Column( Text, ForeignKey("customer.layer_source.name", onupdate="CASCADE"), nullable=True, ) ) style_library_name: str = Field( sa_column=Column( Text, ForeignKey("customer.style_library.name", onupdate="CASCADE"), nullable=True, ) ) max_resolution: Optional[float] = Field( sa_column=Column(Text, nullable=True) ) min_resolution: Optional[float] = Field( sa_column=Column(Text, nullable=True) ) style_library: "StyleLibrary" = Relationship(back_populates="layer_libraries")
class UserBase(SQLModel): name: str = Field(sa_column=Column(Text, nullable=False)) surname: str = Field(sa_column=Column(Text, nullable=False)) email: EmailStr = Field(sa_column=Column(Text, nullable=False)) organization_id: int = Field(sa_column=Column( Integer, ForeignKey("customer.organization.id", ondelete="CASCADE"), nullable=False)) active_study_area_id: int = Field(sa_column=Column( Integer, ForeignKey("basic.study_area.id"), nullable=False)) active_data_upload_ids: List[int] = Field( sa_column=Column(ARRAY(Integer()), server_default=text("'{}'::int[]"))) storage: int = Field(sa_column=Column(Integer), nullable=False) limit_scenarios: int = Field(sa_column=Column(Integer), nullable=False)
class UserStudyArea(SQLModel, table=True): __tablename__ = "user_study_area" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))) user_id: int = Field(sa_column=Column(Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False), ) study_area_id: int = Field( sa_column=Column(Integer, ForeignKey("basic.study_area.id", ondelete="CASCADE"), nullable=False))
class OpportunityDefaultConfig(OpportunityConfigBase, table=True): __tablename__ = "opportunity_default_config" __table_args__ = {"schema": "basic"} opportunity_group_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("basic.opportunity_group.id"), nullable=False)) opportunity_group: "OpportunityGroup" = Relationship( back_populates="opportunity_default_configs")
class PoiModified(PoiBase, table=True): __tablename__ = "poi_modified" __table_args__ = {"schema": "customer"} uid: str = Field(sa_column=Column(Text, nullable=False, index=True)) edit_type: str = Field(sa_column=Column(Text, nullable=False, index=True)) creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))) scenario_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), nullable=False, index=True), ) data_upload_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.data_upload.id", ondelete="CASCADE"), index=True), ) outdated: Optional[bool] = Field(sa_column=Column(Boolean, default=False)) scenario: Optional["Scenario"] = Relationship( back_populates="pois_modified")
class Population(PopulationBase, table=True): __tablename__ = "population" __table_args__ = {"schema": "basic"} demography: Optional[dict] = Field(sa_column=Column(JSONB)) building_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("basic.building.id", ondelete="CASCADE"), index=True), ) building: Optional["Building"] = Relationship(back_populates="populations")
class OpportunityUserConfig(OpportunityConfigBase, table=True): __tablename__ = "opportunity_user_config" __table_args__ = {"schema": "customer"} opportunity_group_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("basic.opportunity_group.id"), nullable=False)) study_area_id: int = Field( sa_column=Column(Integer, ForeignKey("basic.study_area.id"))) user_id: int = Field(sa_column=Column( Integer, ForeignKey("customer.user.id", ondelete="CASCADE"))) data_upload_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.data_upload.id", ondelete="CASCADE"))) study_area: "StudyArea" = Relationship( back_populates="opportunity_user_configs") user: "******" = Relationship(back_populates="opportunity_user_configs") opportunity_group: "OpportunityGroup" = Relationship( back_populates="opportunity_user_configs")
class ReachedPoiHeatmap(SQLModel, table=True): __tablename__ = "reached_poi_heatmap" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) costs: int = Field(sa_column=Column(ARRAY(Integer()), nullable=False)) grid_visualization_ids: int = Field(sa_column=Column( ARRAY(BigInteger()), nullable=False, ), ) poi_uid: str = Field(sa_column=Column(Text, nullable=False), index=True) scenario_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True), ) data_upload_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.data_upload.id", ondelete="CASCADE"), index=True), ) accessibility_indices: list = Field( sa_column=Column(ARRAY(Integer()), nullable=False))
class AoiModified(AoiBase, table=True): __tablename__ = "aoi_modified" __table_args__ = {"schema": "customer"} creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))) scenario_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True)) scenario: Optional["Scenario"] = Relationship( back_populates="aois_modified")
class PopulationModified(PopulationBase, table=True): __tablename__ = "population_modified" __table_args__ = {"schema": "customer"} creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))) building_modified_id: int = Field(sa_column=Column( Integer, ForeignKey("customer.building_modified.id", ondelete="CASCADE"), index=True, nullable=False, ), ) scenario_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True, nullable=False, ), ) building_modified: "BuildingModified" = Relationship( back_populates="populations_modified") scenario: Optional["Scenario"] = Relationship( back_populates="populations_modified")
class PopulationBase(SQLModel): id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) sub_study_area_id: int = Field(sa_column=Column( Integer, ForeignKey("basic.sub_study_area.id", ondelete="CASCADE"), index=True)) population: Optional[float] = Field(sa_column=Column(Float(53))) geom: str = Field(sa_column=Column( Geometry(geometry_type="Point", srid="4326", spatial_index=False), nullable=False, )) sub_study_area: Optional["SubStudyArea"] = Relationship( back_populates="populations")
class Customization(SQLModel, table=True): __tablename__ = "customization" __table_args__ = {"schema": "customer"} id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True)) type: str = Field(sa_column=Column(Text, nullable=False)) setting: dict = Field(sa_column=Column(JSONB, nullable=False)) role_id: int = Field( sa_column=Column( Integer, ForeignKey("customer.role.id", ondelete="CASCADE"), nullable=False ) ) role: "Role" = Relationship(back_populates="customizations") user_customizations: Optional[List["UserCustomization"]] = Relationship(back_populates="customizations")
class AoiUser(AoiBase, table=True): __tablename__ = "aoi_user" __table_args__ = {"schema": "customer"} creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))) data_upload_id: int = Field(sa_column=Column( Integer, ForeignKey("customer.data_upload.id", ondelete="CASCADE"), index=True, nullable=False, )) data_upload: Optional["DataUpload"] = Relationship( back_populates="aois_user")
class ReachedEdgeFullHeatmap(SQLModel, table=True): __tablename__ = "reached_edge_full_heatmap" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) geom: str = Field(sa_column=Column( Geometry(geometry_type="Linestring", srid="4326", spatial_index=False), nullable=False, )) edge_id: int = Field(sa_column=Column(Integer, index=True, nullable=False), ) scenario_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True), )
class WayModified(EdgeBase, table=True): __tablename__ = "way_modified" __table_args__ = {"schema": "customer"} id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True)) way_type: Optional[str] = Field(sa_column=Column(Text)) edit_type: Optional[str] = Field(sa_column=Column(Text)) creation_date: Optional[datetime] = Field( sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")) ) way_id: Optional[int] = Field(index=True, default=None, foreign_key="basic.edge.id") scenario_id: Optional[int] = Field( sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True ) ) outdated: Optional[bool] = Field(sa_column=Column(Boolean, default=False)) scenario: Optional["Scenario"] = Relationship(back_populates="ways_modified")
class GridCalculation(SQLModel, table=True): __tablename__ = "grid_calculation" __table_args__ = {"schema": "basic"} id: Optional[int] = Field( # TODO: Add next value to the sequence sa_column=Column(BigInteger(), primary_key=True, autoincrement=False) ) geom: str = Field( sa_column=Column( Geometry(geometry_type="Polygon", srid="4326", spatial_index=False), nullable=False, ) ) grid_visualization_id: int = Field( sa_column=Column( BigInteger, ForeignKey("basic.grid_visualization.id", ondelete="CASCADE"), nullable=False, ) ) grid_visualization: "GridVisualization" = Relationship(back_populates="grid_calculations")
class ReachedEdgeHeatmapGridCalculation(SQLModel, table=True): __tablename__ = "reached_edge_heatmap_grid_calculation" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(BigInteger(), primary_key=True, autoincrement=True)) start_cost: int = Field(sa_column=Column(SmallInteger, nullable=False)) end_cost: int = Field(sa_column=Column(SmallInteger, nullable=False)) start_perc: int = Field(sa_column=Column(SmallInteger, nullable=True)) end_perc: int = Field(sa_column=Column(SmallInteger, nullable=True)) grid_calculation_id: int = Field(sa_column=Column( BigInteger, ForeignKey("basic.grid_calculation.id", ondelete="CASCADE"), nullable=False, index=True, )) reached_edge_heatmap_id: int = Field(sa_column=Column( Integer, nullable=False, index=True, )) edge_type: str = Field(sa_column=Column(String(2)))
class IsochroneFeature(SQLModel, table=True): __tablename__ = "isochrone_feature" __table_args__ = {"schema": "customer"} id: Optional[int] = Field( sa_column=Column(Integer, primary_key=True, autoincrement=True)) step: int = Field(nullable=False) reached_opportunities: Optional[dict] = Field( sa_column=Column(JSONB, server_default=text("1::jsonb"))) geom: str = Field(sa_column=Column( Geometry( geometry_type="MultiPolygon", srid="4326", spatial_index=False), nullable=False, )) isochrone_calculation_id: int = Field(sa_column=Column( Integer, ForeignKey("customer.isochrone_calculation.id", ondelete="CASCADE"), index=True, nullable=False, )) isochrone_calculation: "IsochroneCalculation" = Relationship( back_populates="isochrone_features")
class Edge(EdgeBase, table=True): __tablename__ = "edge" __table_args__ = {"schema": "basic"} length_m: float = Field(sa_column=Column(Float(53), nullable=False)) length_3857: float = Field(sa_column=Column(Float(53), nullable=False)) coordinates_3857: Optional[dict] = Field(sa_column=Column(JSON, nullable=False)) source: int = Field(index=True, nullable=False, foreign_key="basic.node.id") target: int = Field(index=True, nullable=False, foreign_key="basic.node.id") edge_id: Optional[int] = Field(index=True, default=None, foreign_key="basic.edge.id") scenario_id: Optional[int] = Field( sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True ) ) node_source: "Node" = Relationship( sa_relationship_kwargs={"primaryjoin": "Edge.source==Node.id", "lazy": "joined"} ) node_target: "Node" = Relationship( sa_relationship_kwargs={"primaryjoin": "Edge.target==Node.id", "lazy": "joined"} ) scenario: Optional["Scenario"] = Relationship(back_populates="edges")
class Node(SQLModel, table=True): __tablename__ = "node" __table_args__ = {"schema": "basic"} id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True)) osm_id: Optional[int] = Field(sa_column=Column(BigInteger())) cnt: Optional[int] class_ids: Optional[List[int]] = Field(sa_column=Column(ARRAY(Integer))) foot: Optional[str] = Field(sa_column=Column(ARRAY(Text()))) bicycle: Optional[str] = Field(sa_column=Column(ARRAY(Text()))) lit_classified: Optional[str] = Field(sa_column=Column(ARRAY(Text()))) wheelchair_classified: Optional[str] = Field( sa_column=Column(ARRAY(Text()))) death_end: Optional[bool] = Field(index=True) geom: str = Field(sa_column=Column( Geometry(geometry_type="Point", srid="4326", spatial_index=False), nullable=False, )) scenario_id: Optional[int] = Field(sa_column=Column( Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE"), index=True)) scenario: Optional["Scenario"] = Relationship(back_populates="nodes")
SQLALCHEMY_DATABASE_URL = "mysql+pymysql://{username}:{password}@{server}/{db}".format( username=settings.DATABASE_USER, password=settings.DATABASE_PASSWORD, server=settings.DATABASE_SERVER, db=settings.DATABASE_NAME, ) engine = create_engine(SQLALCHEMY_DATABASE_URL) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) # Based on Postgres and MySQL INTEGER_SIZE = 2147483647 @as_declarative() class Base: id: Any __name__: str # class PlayerServerLink(SQLModel, table=True): # player_id: Optional[int] = Field(foreign_key="player.id") # server_id: Optional[int] = Field(foreign_key="server.id") player_server_association = Table( "players_servers", SQLModel.metadata, Column("player_id", Integer, ForeignKey("player.id")), Column("server_id", Integer, ForeignKey("server.id")), )