コード例 #1
0
ファイル: zapr1.py プロジェクト: screJet/introsqlalchemy
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()
コード例 #2
0
ファイル: query_3.py プロジェクト: Kirill-Pinyaev/flask4
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()
コード例 #3
0
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()
コード例 #4
0
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()
コード例 #5
0
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()
コード例 #6
0
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()
コード例 #7
0
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()
コード例 #8
0
ファイル: zapr6.py プロジェクト: screJet/introsqlalchemy
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)
コード例 #9
0
ファイル: main.py プロジェクト: Kirill-Pinyaev/flask4
def main():
    db_session.global_init("db/mars_explorer.sqlite")

    app.run()