@@ -45,21 +45,22 @@ def getconn() -> pymysql.connections.Connection:
4545 pool = sqlalchemy .create_engine (
4646 "mysql+pymysql://" ,
4747 creator = getconn ,
48+ execution_options = {"isolation_level" : "AUTOCOMMIT" },
4849 )
4950 return pool
5051
5152
5253def test_connector_with_credentials () -> None :
5354 """Test Connector object connection with credentials loaded from file."""
54- credentials , project = google .auth .load_credentials_from_file (
55+ credentials , _ = google .auth .load_credentials_from_file (
5556 os .environ ["GOOGLE_APPLICATION_CREDENTIALS" ]
5657 )
5758 custom_connector = Connector (credentials = credentials )
5859 try :
5960 pool = init_connection_engine (custom_connector )
6061
6162 with pool .connect () as conn :
62- conn .execute ("SELECT 1" )
63+ conn .execute (sqlalchemy . text ( "SELECT 1" ) )
6364
6465 except Exception as e :
6566 logging .exception ("Failed to connect with credentials from file!" , e )
@@ -76,10 +77,10 @@ def test_multiple_connectors() -> None:
7677 pool2 = init_connection_engine (second_connector )
7778
7879 with pool .connect () as conn :
79- conn .execute ("SELECT 1" )
80+ conn .execute (sqlalchemy . text ( "SELECT 1" ) )
8081
8182 with pool2 .connect () as conn :
82- conn .execute ("SELECT 1" )
83+ conn .execute (sqlalchemy . text ( "SELECT 1" ) )
8384
8485 instance_connection_string = os .environ ["MYSQL_CONNECTION_NAME" ]
8586 assert instance_connection_string in first_connector ._instances
@@ -108,7 +109,7 @@ def get_time() -> datetime.datetime:
108109
109110 # connect to database and get current time
110111 with pool .connect () as conn :
111- current_time = conn .execute ("SELECT NOW()" ).fetchone ()
112+ current_time = conn .execute (sqlalchemy . text ( "SELECT NOW()" ) ).fetchone ()
112113
113114 # close connector
114115 default_connector .close ()
@@ -127,7 +128,7 @@ def test_connector_as_context_manager() -> None:
127128 pool = init_connection_engine (connector )
128129
129130 with pool .connect () as conn :
130- conn .execute ("SELECT 1" )
131+ conn .execute (sqlalchemy . text ( "SELECT 1" ) )
131132
132133
133134def test_connector_with_custom_loop () -> None :
@@ -141,7 +142,7 @@ def test_connector_with_custom_loop() -> None:
141142 pool = init_connection_engine (connector )
142143
143144 with pool .connect () as conn :
144- result = conn .execute ("SELECT 1" ).fetchone ()
145+ result = conn .execute (sqlalchemy . text ( "SELECT 1" ) ).fetchone ()
145146 assert result [0 ] == 1
146147 # assert that Connector does not start its own thread
147148 assert connector ._thread is None
0 commit comments