diff options
| -rw-r--r-- | python/load_indicative.py | 10 | ||||
| -rw-r--r-- | sql/et_tables.sql | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/python/load_indicative.py b/python/load_indicative.py index 1c8bf770..feae9e0f 100644 --- a/python/load_indicative.py +++ b/python/load_indicative.py @@ -89,7 +89,11 @@ def upload_deal_data(conn, filename): sqlstr = "select dealname, array_agg(\"Latest Update\") from clo_universe group by dealname" with conn.cursor() as c: c.execute(sqlstr) - deallist = dict(c) + deallist1 = dict(c) + sqlstr = "select dealname from deal_indicative" + with conn.cursor() as c: + c.execute(sqlstr) + deallist2 = [d[0] for d in c] conn.commit() with open( filename, "r") as fh: dr = csv.DictReader(fh, dialect='excel-tab') @@ -124,7 +128,7 @@ def upload_deal_data(conn, filename): dealname = line['Deal/Tranche ID'] line['defaultedbal'] = line["CDO Defaulted Security Balance (Reported)"] - if dealname not in deallist: + if dealname not in deallist2: for key in ["Orig Deal Bal", "Tranche Orig Bal"]: if line[key]: line[key] = sanitize_float(line[key]) @@ -140,7 +144,7 @@ def upload_deal_data(conn, filename): except (psycopg2.DataError, KeyError) as detail: logging.error(detail) pdb.set_trace() - if dealname not in deallist or line['Latest Update'] not in deallist[dealname]: + if dealname not in deallist1 or line['Latest Update'] not in deallist1[dealname]: sqlstring = \ "INSERT INTO clo_universe " \ "VALUES (%(Deal/Tranche ID)s, %(Curr Deal Bal)s, %(Tranche Curr Bal)s, " \ diff --git a/sql/et_tables.sql b/sql/et_tables.sql index d27b72d8..84376bb2 100644 --- a/sql/et_tables.sql +++ b/sql/et_tables.sql @@ -231,7 +231,7 @@ CREATE TABLE clo_universe_old ( ); CREATE TABLE clo_universe ( - dealname varchar(10), + dealname varchar(10) FOREIGN KEY REFERENCES deal_indicative, "Curr Deal Bal" float, "Curr Collat Bal" float, "Tranche Factor" float, |
