@@ -2498,10 +2498,8 @@ def test_sqlalchemy_integer_overload_mapping(conn, request, integer):
2498
2498
sql .SQLTable ("test_type" , db , frame = df )
2499
2499
2500
2500
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 ):
2503
2502
pytest .importorskip ("sqlalchemy" )
2504
- conn = request .getfixturevalue (conn )
2505
2503
# Test read_sql and .to_sql method with a database URI (GH10654)
2506
2504
# db_uri = 'sqlite:///:memory:' # raises
2507
2505
# sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near
@@ -2520,10 +2518,8 @@ def test_database_uri_string(conn, request, test_frame1):
2520
2518
2521
2519
2522
2520
@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 ):
2525
2522
pytest .importorskip ("sqlalchemy" )
2526
- conn = request .getfixturevalue (conn )
2527
2523
# using driver that will not be installed on CI to trigger error
2528
2524
# in sqlalchemy.create_engine -> test passing of this error to user
2529
2525
db_uri = "postgresql+pg8000://user:pass@host/dbname"
@@ -2731,25 +2727,26 @@ def test_delete_rows_is_atomic(conn_name, request):
2731
2727
replacing_df = DataFrame ({"a" : [5 , 6 , 7 ], "b" : [8 , 8 , 8 ]}, dtype = "int32" )
2732
2728
2733
2729
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 )
2735
2733
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 )
2738
2736
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
+ )
2741
2743
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
2744
2745
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"
2747
2748
)
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 )
2753
2750
2754
2751
2755
2752
@pytest .mark .parametrize ("conn" , all_connectable )
@@ -2759,10 +2756,10 @@ def test_roundtrip(conn, request, test_frame1):
2759
2756
2760
2757
conn_name = conn
2761
2758
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" )
2766
2763
2767
2764
if "adbc" in conn_name :
2768
2765
result = result .rename (columns = {"__index_level_0__" : "level_0" })
@@ -3577,13 +3574,6 @@ def test_options_get_engine():
3577
3574
assert isinstance (get_engine ("sqlalchemy" ), SQLAlchemyEngine )
3578
3575
3579
3576
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
-
3587
3577
@pytest .mark .parametrize ("conn" , all_connectable )
3588
3578
@pytest .mark .parametrize ("func" , ["read_sql" , "read_sql_query" ])
3589
3579
def test_read_sql_dtype_backend (
0 commit comments