aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/upload_bbh_trades.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/python/upload_bbh_trades.py b/python/upload_bbh_trades.py
index d827e3ee..2f9fa0b8 100644
--- a/python/upload_bbh_trades.py
+++ b/python/upload_bbh_trades.py
@@ -56,9 +56,18 @@ if __name__ == "__main__":
],
)
try:
- df.to_sql(
- "bbh_bond_upload", dawn_engine, index=False, if_exists="append"
- )
+ try:
+ df.to_sql(
+ "bbh_bond_upload", dawn_engine, index=False, if_exists="append"
+ )
+ except IntegrityError:
+ conn.rollback()
+ df["Client Reference Number"] = df["Client Reference Number"] + "-U"
+ df = pd.read_sql_query(
+ "SELECT * FROM bbh_bond_upload where tradeid=%s",
+ dawn_engine,
+ params=(obj["tradeid"],),
+ )
except IntegrityError:
conn.rollback()
else: