Advertisement
MichalDK

Untitled

Apr 11th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. from sqlalchemy.ext.declarative import declarative_base
  2. from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, types
  3.  
  4. Base =declarative_base()
  5.  
  6. # sql = """
  7. # CREATE TABLE IF NOT EXISTS `bikesharing` (
  8. # `tstamp` timestamp,
  9. # `cnt` integer,
  10. # `temperature` decimal(5, 2),
  11. # `temperature_feels` decimal(5, 2),
  12. # `humidity` decimal(4, 1),
  13. # `wind_speed` decimal(5,2),
  14. # `weather_code` integer,
  15. # `is_holiday` boolean,
  16. # `is_weekend` boolean,
  17. # `season` integer
  18. # );
  19. # """
  20. #trida bikesharing
  21. class BikeSharing(Base):
  22.     __tablename__="bikesharing" # nazev tabulky
  23.     # definujeme sloupce tabulky
  24.     id = Column(Integer, primary_key=True, autoincrement=True)
  25.     tstamp = Column(DateTime)
  26.     cnt = Column(Integer)
  27.     temperature = Column(types.DECIMAL(5, 2))
  28.     humidity = Column(types.DECIMAL(4, 1))
  29.     wind_speed = Column(types.DECIMAL(5, 2))
  30.     weather_code = Column (Integer)
  31.     is_holiday = Column(types.BOOLEAN)
  32.     season = Column(Integer)
  33.  
  34. # #
  35. # #trida Season
  36. class Season(Base):
  37.     __tablename__ = "season"
  38.     number=Column(Integer, ForeignKey(BikeSharing.season), primary_key=True, unique = True)
  39.     season = Column(String(255))
  40. #
  41. # # #weather_code
  42. # class Weathercode(Base):
  43. #     __tablename__ = "weathercode"
  44. #     code=Column(Integer, ForeignKey(BikeSharing.weather_code), primary_key=True, unique = True)
  45. #     weather = Column(String(255))
  46.  
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement