You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1KB

  1. from sqlalchemy import create_engine, Column, Integer, String, DateTime
  2. from sqlalchemy.ext.declarative import declarative_base
  3. from sqlalchemy.orm import sessionmaker
  4. Base = declarative_base()
  5. def init(config):
  6. """
  7. Returns the engine after creating all tables if needed.
  8. """
  9. engine = create_engine(config.get('DB', 'path'), echo=False)
  10. Base.metadata.create_all(engine)
  11. return engine
  12. def get_session(engine):
  13. return sessionmaker(bind=engine)
  14. class Passes(Base):
  15. __tablename__ = 'passes'
  16. id = Column(Integer, primary_key=True)
  17. sat_name = Column(String, nullable=False)
  18. automate_started = Column(DateTime, nullable=False)
  19. aos_time = Column(DateTime, nullable=False)
  20. los_time = Column(DateTime, nullable=False)
  21. max_elev = Column(Integer, nullable=False)
  22. record_time = Column(Integer, nullable=False)
  23. sat_type = Column(String, nullable=True)
  24. def __repr__(self):
  25. return "<Passes(id='%i', sat='%s', aos='%s', los='%s', max_elev='%i')>".format(
  26. self.id, self.sat_name, self.aos_time, self.los_time, self.max_elev
  27. )