aboutsummaryrefslogtreecommitdiffstats
path: root/python/facility_download.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/facility_download.py')
-rw-r--r--python/facility_download.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/python/facility_download.py b/python/facility_download.py
new file mode 100644
index 00000000..b189f536
--- /dev/null
+++ b/python/facility_download.py
@@ -0,0 +1,39 @@
+import requests
+import os
+import common
+
+legal = 'serecap'
+username = 'serecapuser'
+password = 'Welcome1'
+
+# sqlstring = "SELECT DISTINCT LoanXID from markit_prices";
+# common.cursor.execute(sqlstring)
+
+flag = False
+
+# with open( os.path.join(common.root, "data", "Facility files",
+# "facility_latest.csv"), "wb") as fh:
+# for loanxid in common.cursor.fetchall():
+# 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")
+# else:
+# fh.write(r.content.split('\n')[0] + "\n")
+# 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)
+with open( os.path.join(common.root, "data", "Facility files",
+ "facility_test.csv"), "wb") as fh:
+ for loanxid in common.cursor.fetchall():
+ 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")
+ else:
+ fh.write(r.content.split('\n')[0] + "\n")
+ fh.write(r.content.split('\n')[1] + "\n")
+ flag = True
+
+common.cursor.close()
+common.conn.close()