def main(): db_session.global_init("db/mars_explorer_3.sqlite") # app.run() session = db_session.create_session() for user in session.query(User).filter(User.address == "module_1"): print(user) session.commit()
def main(): db_session.global_init("db/mars_explorer.sqlite") # app.run() session = db_session.create_session() for user in session.query(User).filter(User.age < 18): print(f"{user} {user.age} years") session.commit()
def main(): db_session.global_init("db/mars_explorer.sqlite") # app.run() session = db_session.create_session() for user in session.query(User).all(): print(user) session.commit()
def main(): db_session.global_init("db/mars_explorer_3.sqlite") # app.run() session = db_session.create_session() for job in session.query(Jobs).filter((Jobs.work_size < 20), Jobs.is_finished == 0): print(job) session.commit()
def main(): db_session.global_init("db/mars_explorer.sqlite") # app.run() session = db_session.create_session() for user in session.query(User).filter((User.position.like("%chief%")) | User.position.like("%middle%")): print(f"{user} {user.position}") session.commit()
def main(): db_session.global_init("db/mars_explorer_3.sqlite") # app.run() session = db_session.create_session() for user in session.query(User).filter( User.address == "module_1", User.speciality.notlike("%ingeneer%"), User.position.notlike("%ingeneer%")): print(user.id) session.commit()
def main(): db_session.global_init("db/mars_explorer.sqlite") # app.run() session = db_session.create_session() collaborations = {x.id: len(x.collaborators.split()) for x in session.query(Jobs).all()} max_size = max(collaborations.values()) ids = [x for x in collaborations if collaborations[x] == max_size] teamleaders = session.query(User).filter(User.id.in_(ids)) for member in teamleaders: print(member.name, member.surname) session.commit()
def main(): db_session.global_init("db/mars_explorer_1.sqlite") # app.run() session = db_session.create_session() # dictionary of job_id and len of collaboration collaborations = { x.id: len(x.collaborators.split()) for x in session.query(Jobs).all() } max_size = max(collaborations.values()) # job_id if len collaboration is max ids = [x for x in collaborations if collaborations[x] == max_size] # teamleader id if job id in ids temp = [x.team_leader for x in session.query(Jobs).all() if x.id in ids] # result teamleaders = session.query(User).filter(User.id.in_(temp)).all() for member in teamleaders: print(member.name, member.surname)
def main(): db_session.global_init("db/mars_explorer.sqlite") app.run()