diff options
Diffstat (limited to 'python/load_intex_collateral.py')
| -rw-r--r-- | python/load_intex_collateral.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/python/load_intex_collateral.py b/python/load_intex_collateral.py index a7a0336b..e78444cd 100644 --- a/python/load_intex_collateral.py +++ b/python/load_intex_collateral.py @@ -87,22 +87,21 @@ def upload_data(dealnames, workdate, conn): data.append(r) sqlstr = "select distinct(updatedate) from et_collateral where dealname= %s" - old_update_dates = [date[0] for date in query_db(sqlstr, params=(dealname,), one=False)] + old_update_dates = [date[0] for date in query_db(conn, sqlstr, params=(dealname,), one=False)] sqlstr = 'select max("Latest Update") from clo_universe where dealname= %s' - updatedate = query_db(sqlstr, params=(dealname,))[0] + updatedate = query_db(conn, sqlstr, params=(dealname,))[0] reinsert = False if updatedate in old_update_dates: sqlstr = "SELECT count(*) FROM et_collateral where dealname = %s and updatedate= %s" - currlen = query_db(sqlstr, params = (dealname, updatedate))[0] + currlen = query_db(conn, sqlstr, params = (dealname, updatedate))[0] if currlen != len(data): print("{0} has {1} rows in the database and current collateral file has {2}".format(dealname, currlen, len(data))) - c = conn.cursor() - sqlstr = "DELETE FROM et_collateral where dealname = %s and updatedate = %s" - c.execute(sqlstr, (dealname, updatedate)) + with conn.cursor() as c: + sqlstr = "DELETE FROM et_collateral where dealname = %s and updatedate = %s" + c.execute(sqlstr, (dealname, updatedate)) conn.commit() - c.close() reinsert = True if reinsert or not old_update_dates or updatedate not in old_update_dates: tag = 0 |
