Next / Previous / Contents / NM Tech homepage

9.5. transloader: copyCir(): Copy data for one circle

# - - -   c o p y C i r

def copyCir(my, db, cir):
    '''Copy the data for one circle.

      [ (my is a MyCBC instance) and (db is a CBCData instance) and
        (cir is a MyCBC.Cir instance) ->
           db  :=  db + (all data for cir) ]

To preserve all the data for one circle in the old database, we need to add rows to up to five tables: circles, cir_reg, cir_physio, efforts. The first three are built in Section 9.6, “transloader: addCircle(),

    #-- 1 --
    # [ db.s  +:=  a circle row and related cir_reg and cir_physio
    #              rows added, made from cir ]
    t0 = Timer('Adding circle %s' % cir.lat_lon)
    addCircle(my, db, cir)

That takes care of all the one-per-circle items. Items related to circle-years are processed in Section 9.7, “transloader: addCircleYear().

    #-- 2 --
    # [ db.s  +:=  all circle-year data from db for cir ]
    for stnd in my.genStnds(cir.lat_lon):
        addCircleYear(my, db, stnd)

So far all those added rows are in the session, db.s; now commit them.

    #-- 3 --
    # [ db  :=  db with transactions in db.s committed ]
    print t0