test-entity #6
@ -1,6 +1,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, DeclarativeBase
|
from sqlalchemy import Integer, ForeignKey, String
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, DeclarativeBase, relationship
|
||||||
from sqlalchemy.dialects.mysql import TIMESTAMP, TIME, VARCHAR
|
from sqlalchemy.dialects.mysql import TIMESTAMP, TIME, VARCHAR
|
||||||
|
|
||||||
|
|
||||||
@ -34,3 +35,32 @@ class Weather(Base):
|
|||||||
WindSpeed: Mapped[float]
|
WindSpeed: Mapped[float]
|
||||||
WindSpeed10Min: Mapped[float]
|
WindSpeed10Min: Mapped[float]
|
||||||
|
|
||||||
|
class WindTurbineType(Base):
|
||||||
|
__tablename__ = 'wind_turbine_type'
|
||||||
|
Id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
Name: Mapped[str] = mapped_column(VARCHAR(255))
|
||||||
|
Height: Mapped[float]
|
||||||
|
BladeLength: Mapped[float]
|
||||||
|
|
||||||
|
|
||||||
|
class WindPark(Base):
|
||||||
|
__tablename__ = 'wind_park'
|
||||||
|
Id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
Name: Mapped[str] = mapped_column(VARCHAR(255))
|
||||||
|
CenterLatitude: Mapped[float]
|
||||||
|
CenterLongitude: Mapped[float]
|
||||||
|
|
||||||
|
|
||||||
|
class WindParkTurbine(Base):
|
||||||
|
__tablename__ = 'wind_park_turbine'
|
||||||
|
|
||||||
|
wind_park_id: Mapped[int] = mapped_column(Integer, ForeignKey('wind_park.id'), primary_key=True)
|
||||||
|
turbine_id: Mapped[int] = mapped_column(Integer, ForeignKey('wind_turbine_type.id'), primary_key=True)
|
||||||
|
x_offset: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
|
y_offset: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
|
angle: Mapped[int] = mapped_column(Integer, nullable=True)
|
||||||
|
comment: Mapped[str] = mapped_column(String(2000), nullable=True)
|
||||||
|
|
||||||
|
# Связи с другими таблицами
|
||||||
|
wind_park: Mapped["WindPark"] = relationship("WindPark", back_populates="wind_park_turbines")
|
||||||
|
turbine: Mapped["WindTurbineType"] = relationship("WindTurbineType", back_populates="turbine_parks")
|
||||||
|
Loading…
Reference in New Issue
Block a user