Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gventuri committed Jul 18, 2024
1 parent 3c9cfb5 commit 1043852
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pandasai/connectors/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ def enable_sql_query(self, table_name=None):

table = table_name or self.name

# Check if the table already exists in DuckDB
existing_tables = duckdb.query("SHOW TABLES").fetchall()

# If the table already exists, drop it
if table in [t[0] for t in existing_tables]:
duckdb.query(f"DROP TABLE {table}")

duckdb_relation = duckdb.from_df(self.pandas_df)
duckdb_relation.create(table)
self.sql_enabled = True
Expand Down

0 comments on commit 1043852

Please sign in to comment.