コード例 #1
0
ファイル: dbutil.py プロジェクト: banga/Physicians-Model
def merge_forecast(forecast_id, iterations, connection):
    ''' Computes the bucket-wise statistics after all iterations of the
        simulation have completed. Subsequently deleting the iteration specific
        data stored previously.
        This assumes that the previous rows are stored with
            ITERATION < iterations
        and stores the new rows with ITERATION=iterations
    '''
    connection.execute('INSERT INTO FORECAST SELECT FORECAST_ID, YEAR, GENDER, \
            AGE, LOCATION, SPECIALTY, sum(HeadcountSigma), \
            sum(HeadcountSigmaSquare), sum(FTESigma), sum(FTESigmaSquare), \
            {0} FROM FORECAST WHERE FORECAST_ID={1} \
            GROUP BY YEAR, GENDER, AGE, LOCATION, SPECIALTY' \
            .format(iterations, forecast_id))
    connection.execute(FORECAST.delete(
        (FORECAST.c.FORECAST_ID==forecast_id) &
        (FORECAST.c.ITERATION < iterations)))
コード例 #2
0
ファイル: dbutil.py プロジェクト: banga/Physicians-Model
def write_forecast(rows, connection):
    connection.execute(FORECAST.insert(rows))
コード例 #3
0
ファイル: dbutil.py プロジェクト: banga/Physicians-Model
def clear_forecast_id(forecast_id, connection):
    connection.execute(FORECAST.delete().where(
        FORECAST.c.FORECAST_ID==forecast_id))