@@ -43,10 +43,10 @@ def test_select_query(trino_connection):
43
43
rows = result .fetchall ()
44
44
assert len (rows ) == 25
45
45
for row in rows :
46
- assert isinstance (row [ ' nationkey' ] , int )
47
- assert isinstance (row [ ' name' ] , str )
48
- assert isinstance (row [ ' regionkey' ] , int )
49
- assert isinstance (row [ ' comment' ] , str )
46
+ assert isinstance (row . nationkey , int )
47
+ assert isinstance (row . name , str )
48
+ assert isinstance (row . regionkey , int )
49
+ assert isinstance (row . comment , str )
50
50
51
51
52
52
def assert_column (table , column_name , column_type ):
@@ -70,8 +70,8 @@ def test_select_specific_columns(trino_connection):
70
70
rows = result .fetchall ()
71
71
assert len (rows ) > 0
72
72
for row in rows :
73
- assert isinstance (row [ ' node_id' ] , str )
74
- assert isinstance (row [ ' state' ] , str )
73
+ assert isinstance (row . node_id , str )
74
+ assert isinstance (row . state , str )
75
75
76
76
77
77
@pytest .mark .skipif (
@@ -82,7 +82,8 @@ def test_select_specific_columns(trino_connection):
82
82
def test_define_and_create_table (trino_connection ):
83
83
engine , conn = trino_connection
84
84
if not engine .dialect .has_schema (conn , "test" ):
85
- engine .execute (sqla .schema .CreateSchema ("test" ))
85
+ with engine .begin () as connection :
86
+ connection .execute (sqla .schema .CreateSchema ("test" ))
86
87
metadata = sqla .MetaData ()
87
88
try :
88
89
sqla .Table ('users' ,
@@ -110,7 +111,8 @@ def test_insert(trino_connection):
110
111
engine , conn = trino_connection
111
112
112
113
if not engine .dialect .has_schema (conn , "test" ):
113
- engine .execute (sqla .schema .CreateSchema ("test" ))
114
+ with engine .begin () as connection :
115
+ connection .execute (sqla .schema .CreateSchema ("test" ))
114
116
metadata = sqla .MetaData ()
115
117
try :
116
118
users = sqla .Table ('users' ,
@@ -139,7 +141,8 @@ def test_insert(trino_connection):
139
141
def test_insert_multiple_statements (trino_connection ):
140
142
engine , conn = trino_connection
141
143
if not engine .dialect .has_schema (conn , "test" ):
142
- engine .execute (sqla .schema .CreateSchema ("test" ))
144
+ with engine .begin () as connection :
145
+ connection .execute (sqla .schema .CreateSchema ("test" ))
143
146
metadata = sqla .MetaData ()
144
147
users = sqla .Table ('users' ,
145
148
metadata ,
@@ -180,10 +183,10 @@ def test_operators(trino_connection):
180
183
rows = result .fetchall ()
181
184
assert len (rows ) == 1
182
185
for row in rows :
183
- assert isinstance (row [ ' nationkey' ] , int )
184
- assert isinstance (row [ ' name' ] , str )
185
- assert isinstance (row [ ' regionkey' ] , int )
186
- assert isinstance (row [ ' comment' ] , str )
186
+ assert isinstance (row . nationkey , int )
187
+ assert isinstance (row . name , str )
188
+ assert isinstance (row . regionkey , int )
189
+ assert isinstance (row . comment , str )
187
190
188
191
189
192
@pytest .mark .skipif (
@@ -216,14 +219,14 @@ def test_textual_sql(trino_connection):
216
219
rows = result .fetchall ()
217
220
assert len (rows ) == 3
218
221
for row in rows :
219
- assert isinstance (row [ ' custkey' ] , int )
220
- assert isinstance (row [ ' name' ] , str )
221
- assert isinstance (row [ ' address' ] , str )
222
- assert isinstance (row [ ' nationkey' ] , int )
223
- assert isinstance (row [ ' phone' ] , str )
224
- assert isinstance (row [ ' acctbal' ] , float )
225
- assert isinstance (row [ ' mktsegment' ] , str )
226
- assert isinstance (row [ ' comment' ] , str )
222
+ assert isinstance (row . custkey , int )
223
+ assert isinstance (row . name , str )
224
+ assert isinstance (row . address , str )
225
+ assert isinstance (row . nationkey , int )
226
+ assert isinstance (row . phone , str )
227
+ assert isinstance (row . acctbal , float )
228
+ assert isinstance (row . mktsegment , str )
229
+ assert isinstance (row . comment , str )
227
230
228
231
229
232
@pytest .mark .skipif (
@@ -323,7 +326,8 @@ def test_json_column(trino_connection, json_object):
323
326
engine , conn = trino_connection
324
327
325
328
if not engine .dialect .has_schema (conn , "test" ):
326
- engine .execute (sqla .schema .CreateSchema ("test" ))
329
+ with engine .begin () as connection :
330
+ connection .execute (sqla .schema .CreateSchema ("test" ))
327
331
metadata = sqla .MetaData ()
328
332
329
333
try :
@@ -351,7 +355,8 @@ def test_get_table_comment(trino_connection):
351
355
engine , conn = trino_connection
352
356
353
357
if not engine .dialect .has_schema (conn , "test" ):
354
- engine .execute (sqla .schema .CreateSchema ("test" ))
358
+ with engine .begin () as connection :
359
+ connection .execute (sqla .schema .CreateSchema ("test" ))
355
360
metadata = sqla .MetaData ()
356
361
357
362
try :
@@ -378,7 +383,8 @@ def test_get_table_names(trino_connection, schema):
378
383
metadata = sqla .MetaData (schema = schema_name )
379
384
380
385
if not engine .dialect .has_schema (conn , schema_name ):
381
- engine .execute (sqla .schema .CreateSchema (schema_name ))
386
+ with engine .begin () as connection :
387
+ connection .execute (sqla .schema .CreateSchema (schema_name ))
382
388
383
389
try :
384
390
sqla .Table (
@@ -388,10 +394,10 @@ def test_get_table_names(trino_connection, schema):
388
394
)
389
395
metadata .create_all (engine )
390
396
view_name = schema_name + ".test_view"
391
- conn .execute (f"CREATE VIEW { view_name } AS SELECT * FROM test_get_table_names" )
397
+ conn .execute (sqla . text ( f"CREATE VIEW { view_name } AS SELECT * FROM test_get_table_names" ) )
392
398
assert sqla .inspect (engine ).get_table_names (schema_name ) == ['test_get_table_names' ]
393
399
finally :
394
- conn .execute (f"DROP VIEW IF EXISTS { view_name } " )
400
+ conn .execute (sqla . text ( f"DROP VIEW IF EXISTS { view_name } " ) )
395
401
metadata .drop_all (engine )
396
402
397
403
@@ -411,7 +417,8 @@ def test_get_view_names(trino_connection, schema):
411
417
metadata = sqla .MetaData (schema = schema_name )
412
418
413
419
if not engine .dialect .has_schema (conn , schema_name ):
414
- engine .execute (sqla .schema .CreateSchema (schema_name ))
420
+ with engine .begin () as connection :
421
+ connection .execute (sqla .schema .CreateSchema (schema_name ))
415
422
416
423
try :
417
424
sqla .Table (
@@ -421,10 +428,10 @@ def test_get_view_names(trino_connection, schema):
421
428
)
422
429
metadata .create_all (engine )
423
430
view_name = schema_name + ".test_get_view_names"
424
- conn .execute (f"CREATE VIEW { view_name } AS SELECT * FROM test_table" )
431
+ conn .execute (sqla . text ( f"CREATE VIEW { view_name } AS SELECT * FROM test_table" ) )
425
432
assert sqla .inspect (engine ).get_view_names (schema_name ) == ['test_get_view_names' ]
426
433
finally :
427
- conn .execute (f"DROP VIEW IF EXISTS { view_name } " )
434
+ conn .execute (sqla . text ( f"DROP VIEW IF EXISTS { view_name } " ) )
428
435
metadata .drop_all (engine )
429
436
430
437
0 commit comments