From 11f7a021bf3e38a1970969caa5d12f222e2ddbe1 Mon Sep 17 00:00:00 2001 From: RichieHakim Date: Mon, 1 Apr 2024 14:43:34 -0400 Subject: [PATCH] Refactor drop_database and drop_table functions to use the correct engine variable --- bnpm/sql_helpers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bnpm/sql_helpers.py b/bnpm/sql_helpers.py index 98adda1..9058304 100644 --- a/bnpm/sql_helpers.py +++ b/bnpm/sql_helpers.py @@ -386,11 +386,11 @@ def drop_database( Additional keyword arguments to be passed to sqlalchemy.create_engine """ engine = sqlalchemy.create_engine(url, **kwargs_connection) - if "mysql" in str(connection.engine): + if "mysql" in str(engine): query = f"DROP DATABASE {database}" - elif "postgresql" in str(connection.engine): + elif "postgresql" in str(engine): query = f"DROP DATABASE {database}" - elif "sqlite" in str(connection.engine): + elif "sqlite" in str(engine): raise ValueError("SQLite does not support this operation") else: raise ValueError("Connection type not recognized") @@ -421,16 +421,16 @@ def drop_table( """ engine = sqlalchemy.create_engine(url, **kwargs_connection) if isinstance(connection, sqlalchemy.engine.base.Connection): - if "mysql" in str(connection.engine): + if "mysql" in str(engine): if database is None: raise ValueError("database must be specified for MySQL") query = f"DROP TABLE {database}.{table}" - elif "postgresql" in str(connection.engine): + elif "postgresql" in str(engine): if database is None: query = f"DROP TABLE {table}" else: query = f"DROP TABLE {database}.{table}" - elif "sqlite" in str(connection.engine): + elif "sqlite" in str(engine): if database is not None: raise ValueError("database must be None for SQLite") query = f"DROP TABLE {table}"