@@ -748,10 +748,10 @@ def postgresql_psycopg2_conn_types(postgresql_psycopg2_engine_types):
748
748
749
749
750
750
@pytest .fixture
751
- def sqlite_str ():
751
+ def sqlite_str (temp_file ):
752
752
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 } "
755
755
756
756
757
757
@pytest .fixture
@@ -817,20 +817,20 @@ def sqlite_conn_types(sqlite_engine_types):
817
817
818
818
819
819
@pytest .fixture
820
- def sqlite_adbc_conn ():
820
+ def sqlite_adbc_conn (temp_file ):
821
821
pytest .importorskip ("pyarrow" )
822
822
pytest .importorskip ("adbc_driver_sqlite" )
823
823
from adbc_driver_sqlite import dbapi
824
824
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 ()
834
834
835
835
836
836
@pytest .fixture
@@ -2504,20 +2504,20 @@ def test_sqlalchemy_integer_overload_mapping(conn, request, integer):
2504
2504
sql .SQLTable ("test_type" , db , frame = df )
2505
2505
2506
2506
2507
- def test_database_uri_string (request , test_frame1 ):
2507
+ def test_database_uri_string (temp_file , request , test_frame1 ):
2508
2508
pytest .importorskip ("sqlalchemy" )
2509
2509
# Test read_sql and .to_sql method with a database URI (GH10654)
2510
2510
# db_uri = 'sqlite:///:memory:' # raises
2511
2511
# sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near
2512
2512
# "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 )
2521
2521
tm .assert_frame_equal (test_frame1 , test_frame2 )
2522
2522
tm .assert_frame_equal (test_frame1 , test_frame3 )
2523
2523
tm .assert_frame_equal (test_frame1 , test_frame4 )
@@ -2581,16 +2581,16 @@ def test_column_with_percentage(conn, request):
2581
2581
tm .assert_frame_equal (res , df )
2582
2582
2583
2583
2584
- def test_sql_open_close (test_frame3 ):
2584
+ def test_sql_open_close (temp_file , test_frame3 ):
2585
2585
# Test if the IO in the database still work if the connection closed
2586
2586
# between the writing and reading (as in many real situations).
2587
2587
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
2591
2591
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 )
2594
2594
2595
2595
tm .assert_frame_equal (test_frame3 , result )
2596
2596
0 commit comments