diff options
Diffstat (limited to 'python/clo_universe.py')
| -rw-r--r-- | python/clo_universe.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/python/clo_universe.py b/python/clo_universe.py index 03904c53..8c37cd5a 100644 --- a/python/clo_universe.py +++ b/python/clo_universe.py @@ -7,7 +7,7 @@ import pdb import re import sys import common -import psycopg2 +from common import query_db def convertToNone(s): return None if s=="-" or s=="" or s == "NR" else s @@ -20,13 +20,14 @@ def sanitize_float(intex_float): intex_float = float(intex_float) return intex_float -def upload_data(workdate, conn, cursor): - cursor.execute("select dealname, max(\"Latest Update\") from clo_universe group by dealname") - deallist = dict(cursor.fetchall()) +def upload_data(workdate, conn): + sqlstr = "select dealname, max(\"Latest Update\") from clo_universe group by dealname" + deallist = dict(query_db(sqlstr, one=False)) universe = os.path.join("data", "clo_universe_intex_" + workdate + ".txt") with open( os.path.join(common.root, universe), "r") as fh: dr = csv.DictReader(fh, dialect='excel-tab') data = [] + c = conn.cursor() for line in dr: if not line ['Deal Name'] or (line['Deal Name'] == 'Unknown Security'): continue @@ -66,7 +67,7 @@ def upload_data(workdate, conn, cursor): "%(Deal Termination Date)s, %(Deal Next Pay Date)s," \ "%(Reinv End Date)s, %(Latest Update)s, %(Deal CUSIP List)s, %(Paid Down)s)" try: - cursor.execute(sqlstring, line) + c.execute(sqlstring, line) deallist[dealname] = line['Latest Update'] except psycopg2.DataError as detail: print(detail) @@ -81,7 +82,6 @@ if __name__ == "__main__": workdate = sys.argv[1] else: workdate = str(datetime.date.today()) - upload_data(workdate, common.conn, common.cursor) - common.cursor.close() + upload_data(workdate, common.conn) common.conn.close() print("done") |
