aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral/__main__.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/collateral/__main__.py')
-rw-r--r--python/collateral/__main__.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py
index 3d234381..5f7311da 100644
--- a/python/collateral/__main__.py
+++ b/python/collateral/__main__.py
@@ -113,17 +113,13 @@ df.strategy = df.strategy.str.replace("^(M_|SER_)?", "", 1, regex=True)
df["fund"] = df.fund.map(fund_mapping)
df = df[["date", "broker", "strategy", "Amount", "Currency", "fund"]]
-conn = dbconn("dawndb")
sql_str = (
"INSERT INTO strategy_im VALUES(%s, %s, %s, %s, %s, %s) "
"ON CONFLICT (date, strategy, broker, fund) DO UPDATE "
"SET currency=EXCLUDED.currency, amount=EXCLUDED.amount"
)
-with conn.cursor() as c:
- for t in df.itertuples(index=False):
- c.execute(sql_str, t)
-conn.commit()
-conn.close()
+with dawn_engine.connect() as conn:
+ conn.execute(sql_str, list(df.itertuples(index=False)))
if args.send_email:
send_email(workdate, df[df.fund == "SERCGMAST"].drop("fund", axis=1))