init_db.py
def init():
    """
    Creates all DB tables and fills Season and ChallengePart
    """
    logging.info("Creating DB")
    db.drop_all()
    db.create_all()

    # season = Season(title='ZS 2020/2021',
    #                 start_date=date(year=2020, month=11, day=12),
    #                 end_date=date(year=2020, month=12, day=20))
    season = Season(title='ZS 2020/2021',
                    start_date=date(year=2020, month=11, day=1),
                    end_date=date(year=2020, month=12, day=20))
    db.session.add(season)
    db.session.flush()

    part = ChallengePart(season_id=season.id,
                         order=0,
                         target='MFF, Ke Karlovu 3',
                         distance=0)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=1,
                         target='Hrčava (nejvýchodnější bod ČR)',
                         distance=500)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=2,
                         target='Nová Sedlica (nejvýchodnější bod SR)',
                         distance=388)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=3,
                         target='Oravská Polhora (nejsevernější bod SR)',
                         distance=324)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=4,
                         target='Varšava',
                         distance=518)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=5,
                         target='Gdaňsk',
                         distance=446)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=6,
                         target='Berlín',
                         distance=685)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=7,
                         target='Brémy',
                         distance=472)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=8,
                         target='Bremenhaven',
                         distance=94)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=9,
                         target='Amsterdam',
                         distance=461)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=10,
                         target='Brussel',
                         distance=260)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=11,
                         target='Lucemburk',
                         distance=269)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=12,
                         target='Paříž',
                         distance=352)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=13,
                         target='Bern',
                         distance=724)
    db.session.add(part)

    part = ChallengePart(season_id=season.id,
                         order=14,
                         target='Monako',
                         distance=650)
    db.session.add(part)

    db.session.commit()

    Creates all DB tables and fills Season and ChallengePart
    
Creates all DB tables and fills Season and ChallengePart
Creates all DB tables and fills Season and ChallengePart
def init():
    logging.info("Creating DB")
    db.drop_all()
    db.create_all()
    season = Season(title='ZS 2020/2021',
                    start_date=date(year=2020, month=11, day=1),
                    end_date=date(year=2020, month=12, day=20))
    db.session.add(season)
    db.session.flush()
    part = ChallengePart(season_id=season.id,
                         order=0,
                         target='MFF, Ke Karlovu 3',
                         distance=0)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=1,
                         target='Hrčava (nejvýchodnější bod ČR)',
                         distance=500)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=2,
                         target='Nová Sedlica (nejvýchodnější bod SR)',
                         distance=388)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=3,
                         target='Oravská Polhora (nejsevernější bod SR)',
                         distance=324)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=4,
                         target='Varšava',
                         distance=518)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=5,
                         target='Gdaňsk',
                         distance=446)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=6,
                         target='Berlín',
                         distance=685)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=7,
                         target='Brémy',
                         distance=472)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=8,
                         target='Bremenhaven',
                         distance=94)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=9,
                         target='Amsterdam',
                         distance=461)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=10,
                         target='Brussel',
                         distance=260)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=11,
                         target='Lucemburk',
                         distance=269)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=12,
                         target='Paříž',
                         distance=352)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=13,
                         target='Bern',
                         distance=724)
    db.session.add(part)
    part = ChallengePart(season_id=season.id,
                         order=14,
                         target='Monako',
                         distance=650)
    db.session.add(part)
    db.session.commit()
def init ( ) : logging . info ( "Creating DB" ) db . drop_all ( ) db . create_all ( ) season = Season ( title = 'ZS 2020/2021' , start_date = date ( year = 2020 , month = 11 , day = 1 ) , end_date = date ( year = 2020 , month = 12 , day = 20 ) ) db . session . add ( season ) db . session . flush ( ) part = ChallengePart ( season_id = season . id , order = 0 , target = 'MFF, Ke Karlovu 3' , distance = 0 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 1 , target = 'Hrčava (nejvýchodnější bod ČR)', distance = 500 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 2 , target = 'Nová Sedlica (nejvýchodnější bod SR)', distance = 388 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 3 , target = 'Oravská Polhora (nejsevernější bod SR)', distance = 324 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 4 , target = 'Varšava', distance = 518 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 5 , target = 'Gdaňsk', distance = 446 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 6 , target = 'Berlín', distance = 685 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 7 , target = 'Brémy', distance = 472 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 8 , target = 'Bremenhaven' , distance = 94 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 9 , target = 'Amsterdam' , distance = 461 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 10 , target = 'Brussel' , distance = 260 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 11 , target = 'Lucemburk' , distance = 269 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 12 , target = 'Paříž', distance = 352 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 13 , target = 'Bern' , distance = 724 ) db . session . add ( part ) part = ChallengePart ( season_id = season . id , order = 14 , target = 'Monako' , distance = 650 ) db . session . add ( part ) db . session . commit ( )
Creates all DB tables and fills Season and ChallengePart
Creates all DB tables and fills Season and ChallengePart
"""
    Creates all DB tables and fills Season and ChallengePart
    """ # season = Season(title='ZS 2020/2021', #                 start_date=date(year=2020, month=11, day=12), #                 end_date=date(year=2020, month=12, day=20))