def run1_deliveries(con, sa, lo, hi, run, br, json_cols=['kd', 'dr'], table='run1'):
    if sqla.inspect(con).has_table(table):
        lo = pd.read_sql(f'select max(blockHeight) + 1 lo from {table}', con).iloc[0].lo
        if_exists = 'append'
    else:
        if_exists = 'replace'
    for blockHeight in range(lo, hi):
        df = provide_deliveries(sa, blockHeight, run, br)
        if (not len(df)):
            continue
        for col in json_cols:
            df[col] = df[col].apply(json.dumps)
        log.info('block %d of %d: %s += %d rows', blockHeight, hi, table, len(df))
        df.to_sql(table, con, if_exists=if_exists, index=False)
        if_exists = 'append'
def run1_deliveries(con, sa, lo, hi, run, br, json_cols=['kd', 'dr'], table='run1'):
    if sqla.inspect(con).has_table(table):
        lo = pd.read_sql(f'select max(blockHeight) + 1 lo from {table}', con).iloc[0].lo
        if_exists = 'append'
    else:
        if_exists = 'replace'
    for blockHeight in range(lo, hi):
        df = provide_deliveries(sa, blockHeight, run, br)
        if (not len(df)):
            continue
        for col in json_cols:
            df[col] = df[col].apply(json.dumps)
        log.info('block %d of %d: %s += %d rows', blockHeight, hi, table, len(df))
        df.to_sql(table, con, if_exists=if_exists, index=False)
        if_exists = 'append'