Skip to content

Commit e62a848

Browse files
committed
revert drop_table error handling
1 parent be28090 commit e62a848

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pandas/tests/io/test_sql.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ def create_and_load_postgres_datetz(conn, table_name):
341341
from sqlalchemy.engine import Engine
342342

343343
metadata = MetaData()
344-
datetz = Table(table_name, metadata, Column("DateColWithTz", DateTime(timezone=True)))
344+
datetz = Table(
345+
table_name, metadata, Column("DateColWithTz", DateTime(timezone=True))
346+
)
345347
datetz_data = [
346348
{
347349
"DateColWithTz": "2000-01-01 00:00:00-08:00",
@@ -565,8 +567,6 @@ def drop_table(
565567
table_name: str,
566568
conn: sqlite3.Connection | sqlalchemy.engine.Engine | sqlalchemy.engine.Connection,
567569
):
568-
import sqlalchemy
569-
570570
if isinstance(conn, sqlite3.Connection):
571571
conn.execute(f"DROP TABLE IF EXISTS {sql._get_valid_sqlite_name(table_name)}")
572572
conn.commit()
@@ -577,12 +577,9 @@ def drop_table(
577577
with conn.cursor() as cur:
578578
cur.execute(f'DROP TABLE IF EXISTS "{table_name}"')
579579
else:
580-
try:
581-
with conn.begin() as con:
582-
with sql.SQLDatabase(con) as db:
583-
db.drop_table(table_name)
584-
except sqlalchemy.exc.ProgrammingError:
585-
pass
580+
with conn.begin() as con:
581+
with sql.SQLDatabase(con) as db:
582+
db.drop_table(table_name)
586583

587584

588585
def drop_view(
@@ -3974,7 +3971,9 @@ def test_psycopg2_schema_support(postgresql_psycopg2_engine):
39743971
con.exec_driver_sql("CREATE SCHEMA other;")
39753972

39763973
schema_public_uuid = create_unique_table_name("test_schema_public")
3977-
schema_public_explicit_uuid = create_unique_table_name("test_schema_public_explicit")
3974+
schema_public_explicit_uuid = create_unique_table_name(
3975+
"test_schema_public_explicit"
3976+
)
39783977
schema_other_uuid = create_unique_table_name("test_schema_other")
39793978

39803979
# write dataframe to different schema's

0 commit comments

Comments
 (0)