Automated Action 2681892abd Add Weather Data API with OpenWeatherMap integration
- Set up FastAPI project structure
- Create database models for locations and weather data
- Implement OpenWeatherMap API integration
- Create API endpoints for current weather and history
- Add health endpoint
- Set up database migrations with Alembic
- Update README with documentation

generated with BackendIM... (backend.im)
2025-05-12 13:35:49 +00:00

38 lines
1.3 KiB
Python

from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from datetime import datetime
from app.core.database import Base
class Location(Base):
__tablename__ = "locations"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True)
country = Column(String)
latitude = Column(Float)
longitude = Column(Float)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
weather_data = relationship("WeatherData", back_populates="location")
class WeatherData(Base):
__tablename__ = "weather_data"
id = Column(Integer, primary_key=True, index=True)
location_id = Column(Integer, ForeignKey("locations.id"))
temperature = Column(Float)
feels_like = Column(Float)
humidity = Column(Integer)
pressure = Column(Integer)
wind_speed = Column(Float)
wind_direction = Column(Integer)
weather_condition = Column(String)
weather_description = Column(String)
clouds = Column(Integer)
timestamp = Column(DateTime, index=True)
created_at = Column(DateTime, default=datetime.utcnow)
location = relationship("Location", back_populates="weather_data")