51 lines
1.5 KiB
Python
Raw Normal View History

2024-10-14 17:06:49 +04:00
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, Mapped, mapped_column
from sqlalchemy.dialects.mysql import TIMESTAMP, TIME, VARCHAR
2024-10-14 17:06:49 +04:00
from datetime import datetime
2024-10-14 17:06:49 +04:00
DATABASE_URL = "mysql+pymysql://wind:wind@193.124.203.110:3306/wind_towers"
engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
class User(Base):
__tablename__ = "user" # Убедитесь, что эта таблица существует
id = Column(Integer, primary_key=True, index=True)
name = Column(String(50), index=True)
class Weather(Base):
__tablename__ = "weather"
id: Mapped[int] = mapped_column(primary_key=True)
BarTrend: Mapped[str] = mapped_column(VARCHAR(255))
CRC: Mapped[str] = mapped_column(VARCHAR(255))
DateStamp: Mapped[datetime] = mapped_column(TIMESTAMP)
DewPoint: Mapped[float]
HeatIndex: Mapped[float]
ETDay: Mapped[float]
HumIn: Mapped[float]
HumOut: Mapped[float]
Pressure: Mapped[float]
RainDay: Mapped[float]
RainMonth: Mapped[float]
RainRate: Mapped[float]
RainStorm: Mapped[float]
RainYear: Mapped[float]
SunRise: Mapped[datetime] = mapped_column(TIME)
SunSet:Mapped[datetime] = mapped_column(TIME)
TempIn: Mapped[float]
TempOut: Mapped[float]
WindDir: Mapped[str] = mapped_column(VARCHAR(50))
WindSpeed: Mapped[float]
WindSpeed10Min: Mapped[float]