diff options
Diffstat (limited to 'python/facility_download.py')
| -rw-r--r-- | python/facility_download.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/python/facility_download.py b/python/facility_download.py index b189f536..f56dae7c 100644 --- a/python/facility_download.py +++ b/python/facility_download.py @@ -1,6 +1,7 @@ import requests
import os
import common
+from common import query_db
legal = 'serecap'
username = 'serecapuser'
@@ -22,11 +23,12 @@ flag = False # fh.write(r.content.split('\n')[1] + "\n")
# flag = True
+
sqlstring = "select loanxid from markit_prices2 except (select loanxid from latest_markit_prices2)"
-common.cursor.execute(sqlstring)
+loan_ids = query_db(sqlstring, one=False)
with open( os.path.join(common.root, "data", "Facility files",
"facility_test.csv"), "wb") as fh:
- for loanxid in common.cursor.fetchall():
+ for loanxid in loan_ids:
r = requests.get('https://loans.markit.com/loanx/LoanXOneFacility.csv?LEGALENTITY={0}&USERNAME={1}&PASSWORD={2}&LOANXID={3}'.format(legal, username, password, loanxid[0]))
if flag:
fh.write(r.content.split('\n')[1] + "\n")
@@ -35,5 +37,4 @@ with open( os.path.join(common.root, "data", "Facility files", fh.write(r.content.split('\n')[1] + "\n")
flag = True
-common.cursor.close()
common.conn.close()
|
