diff options
Diffstat (limited to 'python/markit_red.py')
| -rw-r--r-- | python/markit_red.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/python/markit_red.py b/python/markit_red.py index 513f08e1..09b836e0 100644 --- a/python/markit_red.py +++ b/python/markit_red.py @@ -3,7 +3,7 @@ from lxml import etree import requests, io, zipfile, shutil import common import os -from db import serenitasdb +from db import with_connection def request_payload(payload): r = requests.get('https://www.markit.com/export.jsp', params=payload) @@ -30,7 +30,8 @@ def download_report(report): r += request_payload(payload) return r -def update_redcodes(fname): +@with_connection('serenitasdb') +def update_redcodes(conn, fname): with open(os.path.join(common.root, "Tranche_data", "RED_reports", fname)) as fh: et = etree.parse(fh) r = [] @@ -45,9 +46,9 @@ def update_redcodes(fname): sqlstr = """UPDATE index_version SET redindexcode=%s where index=%s and series=%s and version=%s and indexfactor=%s""" - with serenitasdb.cursor() as c: + with conn.cursor() as c: c.executemany(sqlstr, [tuple([e[3], e[0], e[1], e[2], float(e[4])*100]) for e in r]) - serenitasdb.commit() + conn.commit() def update_redindices(fname): basedir = os.path.join(common.root, "Tranche_Data", "RED_reports") |
