1717
1818import numpy as np
1919import pytest
20- from sqlalchemy import text
21- from sqlalchemy .engine import Connection
20+ from sqlalchemy import (
21+ create_engine ,
22+ text ,
23+ )
24+ from sqlalchemy .engine import Engine
2225
2326from pandas ._config import using_string_dtype
2427
@@ -4353,7 +4356,7 @@ def test_xsqlite_if_exists(sqlite_buildin):
43534356 drop_table (table_name , sqlite_buildin )
43544357
43554358
4356- @pytest .mark .parametrize ("conn" , mysql_connectable + postgresql_connectable )
4359+ @pytest .mark .parametrize ("conn" , sqlalchemy_connectable )
43574360def test_exists_temporary_table (conn , test_frame1 , request ):
43584361 conn = request .getfixturevalue (conn )
43594362
@@ -4372,14 +4375,18 @@ def test_exists_temporary_table(conn, test_frame1, request):
43724375 assert True if table .exists () else False
43734376
43744377
4375- @pytest .mark .parametrize ("conn" , mysql_connectable + postgresql_connectable )
4378+ @pytest .mark .parametrize ("conn" , sqlalchemy_connectable )
43764379def test_to_sql_temporary_table_replace (conn , test_frame1 , request ):
43774380 conn = request .getfixturevalue (conn )
43784381
4379- if isinstance ( conn , Connection ):
4380- con = conn
4381- else :
4382+ # some DBMS only allow temporary tables to exist within a connection, therefore
4383+ # we can only test for a connection and not all types of connectables.
4384+ if isinstance ( conn , Engine ) :
43824385 con = conn .connect ()
4386+ elif isinstance (conn , str ):
4387+ con = create_engine (conn ).connect ()
4388+ else :
4389+ con = conn
43834390
43844391 test_frame1 .to_sql (
43854392 name = "test_frame1" ,
@@ -4402,14 +4409,18 @@ def test_to_sql_temporary_table_replace(conn, test_frame1, request):
44024409 assert_frame_equal (test_frame1 , df_test )
44034410
44044411
4405- @pytest .mark .parametrize ("conn" , mysql_connectable + postgresql_connectable )
4412+ @pytest .mark .parametrize ("conn" , sqlalchemy_connectable )
44064413def test_to_sql_temporary_table_fail (conn , test_frame1 , request ):
44074414 conn = request .getfixturevalue (conn )
44084415
4409- if isinstance ( conn , Connection ):
4410- con = conn
4411- else :
4416+ # some DBMS only allow temporary tables to exist within a connection, therefore
4417+ # we can only test for a connection and not all types of connectables.
4418+ if isinstance ( conn , Engine ) :
44124419 con = conn .connect ()
4420+ elif isinstance (conn , str ):
4421+ con = create_engine (conn ).connect ()
4422+ else :
4423+ con = conn
44134424
44144425 test_frame1 .to_sql (
44154426 name = "test_frame1" ,
0 commit comments