From 11da135ea2fa304d264782af06a13f23979d783e Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Wed, 12 Feb 2025 17:54:46 -0800 Subject: [PATCH] refactor: Prevent duplicate table creation messages in trading_plan table --- src/trading/trading_plan.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/trading/trading_plan.py b/src/trading/trading_plan.py index 5c4bb3c..76dc618 100644 --- a/src/trading/trading_plan.py +++ b/src/trading/trading_plan.py @@ -78,6 +78,18 @@ def create_trading_plan_table(): """Create the trading plans table if it doesn't exist""" with create_client() as client: try: + # First check if table exists + check_query = """ + SELECT name + FROM system.tables + WHERE database = currentDatabase() + AND name = 'trading_plans' + """ + result = client.query(check_query) + + if result.result_rows: + return # Table already exists, silently return + # Create new table with a structure that supports updates query = """ CREATE TABLE IF NOT EXISTS trading_plans