@@ -156,12 +156,11 @@ def test_get_views(engine: Engine) -> None:
156156 views = engine .dialect .get_view_names (con )
157157 assert views == []
158158
159- engine .execute (text ("create view test as select 1" ))
160- engine .execute (
159+ con .execute (text ("create view test as select 1" ))
160+ con .execute (
161161 text ("create schema scheme; create view scheme.schema_test as select 1" )
162162 )
163163
164- con = engine .connect ()
165164 views = engine .dialect .get_view_names (con )
166165 assert views == ["test" ]
167166
@@ -183,7 +182,7 @@ def test_preload_extension() -> None:
183182 # check that we get an error indicating that the extension was loaded
184183 with engine .connect () as conn , raises (Exception , match = "HTTP HEAD" ):
185184 conn .execute (
186- "SELECT * FROM read_parquet('https://domain/path/to/file.parquet');"
185+ text ( "SELECT * FROM read_parquet('https://domain/path/to/file.parquet');" )
187186 )
188187
189188
@@ -307,8 +306,9 @@ def test_inmemory() -> None:
307306 shell = InteractiveShell ()
308307 shell .run_cell ("""import sqlalchemy as sa""" )
309308 shell .run_cell ("""eng = sa.create_engine("duckdb:///:memory:")""" )
310- shell .run_cell ("""eng.execute("CREATE TABLE t (x int)")""" )
311- res = shell .run_cell ("""eng.execute("SHOW TABLES").fetchall()""" )
309+ shell .run_cell ("""conn = eng.connect()""" )
310+ shell .run_cell ("""conn.execute(sa.text("CREATE TABLE t (x int)"))""" )
311+ res = shell .run_cell ("""conn.execute(sa.text("SHOW TABLES")).fetchall()""" )
312312
313313 assert res .result == [("t" ,)]
314314
@@ -329,7 +329,8 @@ def test_config(tmp_path: Path) -> None:
329329 DBAPIError ,
330330 match = 'Cannot execute statement of type "CREATE" (on database "test" which is attached )?in read-only mode!' ,
331331 ):
332- eng .execute ("create table hello2 (i int)" )
332+ with eng .connect () as conn :
333+ conn .execute (text ("create table hello2 (i int)" ))
333334
334335
335336def test_do_ping (tmp_path : Path , caplog : LogCaptureFixture ) -> None :
0 commit comments