@@ -2498,10 +2498,8 @@ def test_sqlalchemy_integer_overload_mapping(conn, request, integer):
24982498            sql .SQLTable ("test_type" , db , frame = df )
24992499
25002500
2501- @pytest .mark .parametrize ("conn" , all_connectable ) 
2502- def  test_database_uri_string (conn , request , test_frame1 ):
2501+ def  test_database_uri_string (request , test_frame1 ):
25032502    pytest .importorskip ("sqlalchemy" )
2504-     conn  =  request .getfixturevalue (conn )
25052503    # Test read_sql and .to_sql method with a database URI (GH10654) 
25062504    # db_uri = 'sqlite:///:memory:' # raises 
25072505    # sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near 
@@ -2520,10 +2518,8 @@ def test_database_uri_string(conn, request, test_frame1):
25202518
25212519
25222520@td .skip_if_installed ("pg8000" ) 
2523- @pytest .mark .parametrize ("conn" , all_connectable ) 
2524- def  test_pg8000_sqlalchemy_passthrough_error (conn , request ):
2521+ def  test_pg8000_sqlalchemy_passthrough_error (request ):
25252522    pytest .importorskip ("sqlalchemy" )
2526-     conn  =  request .getfixturevalue (conn )
25272523    # using driver that will not be installed on CI to trigger error 
25282524    # in sqlalchemy.create_engine -> test passing of this error to user 
25292525    db_uri  =  "postgresql+pg8000://user:pass@host/dbname" 
@@ -2731,25 +2727,26 @@ def test_delete_rows_is_atomic(conn_name, request):
27312727    replacing_df  =  DataFrame ({"a" : [5 , 6 , 7 ], "b" : [8 , 8 , 8 ]}, dtype = "int32" )
27322728
27332729    conn  =  request .getfixturevalue (conn_name )
2734-     pandasSQL  =  pandasSQL_builder (conn )
2730+     with  pandasSQL_builder (conn ) as  pandasSQL :
2731+         with  pandasSQL .run_transaction () as  cur :
2732+             cur .execute (table_stmt )
27352733
2736-     with  pandasSQL .run_transaction ()  as   cur :
2737-         cur . execute ( table_stmt )
2734+          with  pandasSQL .run_transaction ():
2735+              pandasSQL . to_sql ( original_df ,  table_name ,  if_exists = "append" ,  index = False )
27382736
2739-     with  pandasSQL .run_transaction ():
2740-         pandasSQL .to_sql (original_df , table_name , if_exists = "append" , index = False )
2737+         # inserting duplicated values in a UNIQUE constraint column 
2738+         with  pytest .raises (pd .errors .DatabaseError ):
2739+             with  pandasSQL .run_transaction ():
2740+                 pandasSQL .to_sql (
2741+                     replacing_df , table_name , if_exists = "delete_rows" , index = False 
2742+                 )
27412743
2742-     # inserting duplicated values in a UNIQUE constraint column 
2743-     with  pytest .raises (pd .errors .DatabaseError ):
2744+         # failed "delete_rows" is rolled back preserving original data 
27442745        with  pandasSQL .run_transaction ():
2745-             pandasSQL .to_sql (
2746-                 replacing_df ,  table_name ,  if_exists = "delete_rows" ,  index = False 
2746+             result_df   =   pandasSQL .read_query (
2747+                 f"SELECT * FROM  { table_name } " ,  dtype = "int32" 
27472748            )
2748- 
2749-     # failed "delete_rows" is rolled back preserving original data 
2750-     with  pandasSQL .run_transaction ():
2751-         result_df  =  pandasSQL .read_query (f"SELECT * FROM { table_name }  " , dtype = "int32" )
2752-         tm .assert_frame_equal (result_df , original_df )
2749+             tm .assert_frame_equal (result_df , original_df )
27532750
27542751
27552752@pytest .mark .parametrize ("conn" , all_connectable ) 
@@ -2759,10 +2756,10 @@ def test_roundtrip(conn, request, test_frame1):
27592756
27602757    conn_name  =  conn 
27612758    conn  =  request .getfixturevalue (conn )
2762-     pandasSQL   =   pandasSQL_builder (conn )
2763-     with  pandasSQL .run_transaction ():
2764-         assert  pandasSQL .to_sql (test_frame1 , "test_frame_roundtrip" ) ==  4 
2765-         result  =  pandasSQL .read_query ("SELECT * FROM test_frame_roundtrip" )
2759+     with   pandasSQL_builder (conn )  as   pandasSQL : 
2760+          with  pandasSQL .run_transaction ():
2761+              assert  pandasSQL .to_sql (test_frame1 , "test_frame_roundtrip" ) ==  4 
2762+              result  =  pandasSQL .read_query ("SELECT * FROM test_frame_roundtrip" )
27662763
27672764    if  "adbc"  in  conn_name :
27682765        result  =  result .rename (columns = {"__index_level_0__" : "level_0" })
@@ -3577,13 +3574,6 @@ def test_options_get_engine():
35773574        assert  isinstance (get_engine ("sqlalchemy" ), SQLAlchemyEngine )
35783575
35793576
3580- def  test_get_engine_auto_error_message ():
3581-     # Expect different error messages from get_engine(engine="auto") 
3582-     # if engines aren't installed vs. are installed but bad version 
3583-     pass 
3584-     # TODO(GH#36893) fill this in when we add more engines 
3585- 
3586- 
35873577@pytest .mark .parametrize ("conn" , all_connectable ) 
35883578@pytest .mark .parametrize ("func" , ["read_sql" , "read_sql_query" ]) 
35893579def  test_read_sql_dtype_backend (
0 commit comments