From 5acd9df4f0bf46a1e3949a3f775671c0c4ba45e7 Mon Sep 17 00:00:00 2001 From: Oscar Salazar Date: Thu, 4 Jul 2024 14:51:21 -0600 Subject: [PATCH] Update ui.py --- hybrid-tables/python/src/ui.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hybrid-tables/python/src/ui.py b/hybrid-tables/python/src/ui.py index 14764c5..00e4bec 100644 --- a/hybrid-tables/python/src/ui.py +++ b/hybrid-tables/python/src/ui.py @@ -17,8 +17,10 @@ def run(self): st.dataframe(self.session.table('internal.dictionary').to_pandas(), use_container_width=True) def add(self, key: str, value: str): - result = self.session.call('core.add_key_value', key, value) - st.write(json.loads(result)) + result = json.loads(self.session.call('core.add_key_value', key, value)) + if "SQLCODE" in result: + error = f"Primary key violation on Hybrid Table. **{key}** already exists." if result["SQLCODE"] == 200001 else result["SQLERRM"] + st.error(error, icon="🚨") if __name__ == '__main__': ui = UI(Session.builder.getOrCreate())