diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/load_intex_collateral.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/python/load_intex_collateral.py b/python/load_intex_collateral.py index 417cbee4..cfa4d71f 100644 --- a/python/load_intex_collateral.py +++ b/python/load_intex_collateral.py @@ -100,8 +100,17 @@ def upload_data(conn, dealnames, workdate): c.execute(sqlstr, (dealname, updatedate)) conn.commit() reinsert = True + if reinsert or not old_update_dates or updatedate not in old_update_dates: tag = 0 + sql_fields = ["dealname", "updatedate", "name", "IssuerName", "CurrentBalance", + "Maturity", "AssetSubtype", "AssetType", "GrossCoupon", + "Spread", "Frequency", "NextPaydate", "SecondLien", "LoanXID", + "Cusip", "IntexPrice", "IntexPriceSource", "IntexPriceDate", + "FixedOrFloat", "DefaultedFlag", "CovLite", "isCDO", + "Liborfloor", "ReinvFlag", "Currency"] + sqlstr = "INSERT INTO ET_COLLATERAL({0}) VALUES({1})".format(",".join(sql_fields), + ",".join(["%s"] * len(sql_fields))) c = conn.cursor() for row in data: # these next three ifs are to take care of reinvestment asset lines @@ -114,14 +123,7 @@ def upload_data(conn, dealnames, workdate): row[4] = row[4][:9] except (AttributeError, TypeError): pass - sql_fields = ["dealname", "updatedate", "name", "IssuerName", "CurrentBalance", - "Maturity", "AssetSubtype", "AssetType", "GrossCoupon", - "Spread", "Frequency", "NextPaydate", "SecondLien", "LoanXID", - "Cusip", "IntexPrice", "IntexPriceSource", "IntexPriceDate", - "FixedOrFloat", "DefaultedFlag", "CovLite", "isCDO", - "Liborfloor", "ReinvFlag", "Currency"] - sqlstr = "INSERT INTO ET_COLLATERAL({0}) VALUES({1})".format(",".join(sql_fields), - ",".join(["%s"] * len(sql_fields))) + try: c.execute(sqlstr, (dealname, updatedate) + tuple(row)) except psycopg2.DataError as detail: |
