@@ -748,10 +748,10 @@ def postgresql_psycopg2_conn_types(postgresql_psycopg2_engine_types):
748748
749749
750750@pytest .fixture
751- def sqlite_str ():
751+ def sqlite_str (temp_file ):
752752 pytest .importorskip ("sqlalchemy" )
753- with tm . ensure_clean () as name :
754- yield f"sqlite:///{ name } "
753+ name = str ( temp_file )
754+ yield f"sqlite:///{ name } "
755755
756756
757757@pytest .fixture
@@ -817,20 +817,20 @@ def sqlite_conn_types(sqlite_engine_types):
817817
818818
819819@pytest .fixture
820- def sqlite_adbc_conn ():
820+ def sqlite_adbc_conn (temp_file ):
821821 pytest .importorskip ("pyarrow" )
822822 pytest .importorskip ("adbc_driver_sqlite" )
823823 from adbc_driver_sqlite import dbapi
824824
825- with tm . ensure_clean () as name :
826- uri = f"file:{ name } "
827- with dbapi .connect (uri ) as conn :
828- yield conn
829- for view in get_all_views (conn ):
830- drop_view (view , conn )
831- for tbl in get_all_tables (conn ):
832- drop_table (tbl , conn )
833- conn .commit ()
825+ name = str ( temp_file )
826+ uri = f"file:{ name } "
827+ with dbapi .connect (uri ) as conn :
828+ yield conn
829+ for view in get_all_views (conn ):
830+ drop_view (view , conn )
831+ for tbl in get_all_tables (conn ):
832+ drop_table (tbl , conn )
833+ conn .commit ()
834834
835835
836836@pytest .fixture
@@ -2504,20 +2504,20 @@ def test_sqlalchemy_integer_overload_mapping(conn, request, integer):
25042504 sql .SQLTable ("test_type" , db , frame = df )
25052505
25062506
2507- def test_database_uri_string (request , test_frame1 ):
2507+ def test_database_uri_string (temp_file , request , test_frame1 ):
25082508 pytest .importorskip ("sqlalchemy" )
25092509 # Test read_sql and .to_sql method with a database URI (GH10654)
25102510 # db_uri = 'sqlite:///:memory:' # raises
25112511 # sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near
25122512 # "iris": syntax error [SQL: 'iris']
2513- with tm . ensure_clean () as name :
2514- db_uri = "sqlite:///" + name
2515- table = "iris"
2516- test_frame1 .to_sql (name = table , con = db_uri , if_exists = "replace" , index = False )
2517- test_frame2 = sql .read_sql (table , db_uri )
2518- test_frame3 = sql .read_sql_table (table , db_uri )
2519- query = "SELECT * FROM iris"
2520- test_frame4 = sql .read_sql_query (query , db_uri )
2513+ name = str ( temp_file )
2514+ db_uri = "sqlite:///" + name
2515+ table = "iris"
2516+ test_frame1 .to_sql (name = table , con = db_uri , if_exists = "replace" , index = False )
2517+ test_frame2 = sql .read_sql (table , db_uri )
2518+ test_frame3 = sql .read_sql_table (table , db_uri )
2519+ query = "SELECT * FROM iris"
2520+ test_frame4 = sql .read_sql_query (query , db_uri )
25212521 tm .assert_frame_equal (test_frame1 , test_frame2 )
25222522 tm .assert_frame_equal (test_frame1 , test_frame3 )
25232523 tm .assert_frame_equal (test_frame1 , test_frame4 )
@@ -2581,16 +2581,16 @@ def test_column_with_percentage(conn, request):
25812581 tm .assert_frame_equal (res , df )
25822582
25832583
2584- def test_sql_open_close (test_frame3 ):
2584+ def test_sql_open_close (temp_file , test_frame3 ):
25852585 # Test if the IO in the database still work if the connection closed
25862586 # between the writing and reading (as in many real situations).
25872587
2588- with tm . ensure_clean () as name :
2589- with contextlib .closing (sqlite3 .connect (name )) as conn :
2590- assert sql .to_sql (test_frame3 , "test_frame3_legacy" , conn , index = False ) == 4
2588+ name = str ( temp_file )
2589+ with contextlib .closing (sqlite3 .connect (name )) as conn :
2590+ assert sql .to_sql (test_frame3 , "test_frame3_legacy" , conn , index = False ) == 4
25912591
2592- with contextlib .closing (sqlite3 .connect (name )) as conn :
2593- result = sql .read_sql_query ("SELECT * FROM test_frame3_legacy;" , conn )
2592+ with contextlib .closing (sqlite3 .connect (name )) as conn :
2593+ result = sql .read_sql_query ("SELECT * FROM test_frame3_legacy;" , conn )
25942594
25952595 tm .assert_frame_equal (test_frame3 , result )
25962596
0 commit comments