Skip to content

Commit 0e5fb70

Browse files
committed
Use text method wrapper for setup_test_db.py script
1 parent fd5851a commit 0e5fb70

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

setup_test_db.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# flake8: noqa
2+
from sqlalchemy import text
3+
24
import crawler.config.test as config
35
from crawler.db.mysql import create_mysql_connection_engine
46

@@ -11,6 +13,7 @@
1113
create_db = """
1214
CREATE DATABASE IF NOT EXISTS `unified_warehouse_test` /*!40100 DEFAULT CHARACTER SET latin1 */;
1315
"""
16+
1417
drop_table_lh_sample = """
1518
DROP TABLE IF EXISTS `unified_warehouse_test`.`lighthouse_sample`;
1619
"""
@@ -204,25 +207,25 @@
204207
"""
205208

206209
with sql_engine.connect() as connection:
207-
connection.execute(create_db)
210+
connection.execute(text(create_db))
208211

209212
print("*** Dropping table LIGHTHOUSE SAMPLE ***")
210-
connection.execute(drop_table_lh_sample)
213+
connection.execute(text(drop_table_lh_sample))
211214
print("*** Dropping table STOCK RESOURCE ***")
212-
connection.execute(drop_table_stock_resource)
215+
connection.execute(text(drop_table_stock_resource))
213216
print("*** Dropping table STUDY ***")
214-
connection.execute(drop_table_study)
217+
connection.execute(text(drop_table_study))
215218
print("*** Dropping table SAMPLE ***")
216-
connection.execute(drop_table_sample)
219+
connection.execute(text(drop_table_sample))
217220

218221
print("*** Creating table SAMPLE ***")
219-
connection.execute(create_table_sample)
222+
connection.execute(text(create_table_sample))
220223
print("*** Creating table STUDY ***")
221-
connection.execute(create_table_study)
224+
connection.execute(text(create_table_study))
222225
print("*** Creating table STOCK RESOURCE ***")
223-
connection.execute(create_table_stock_resource)
226+
connection.execute(text(create_table_stock_resource))
224227
print("*** Creating table LIGHTHOUSE SAMPLE ***")
225-
connection.execute(create_table_lh_sample)
228+
connection.execute(text(create_table_lh_sample))
226229

227230
print("Initialising the test MySQL events warehouse database")
228231

@@ -370,36 +373,36 @@
370373
"""
371374

372375
with sql_engine.connect() as connection:
373-
connection.execute(create_db)
376+
connection.execute(text(create_db))
374377

375378
print("*** Dropping view CHERRYPICKED SAMPLES ***")
376-
connection.execute(drop_view_cherrypicked_samples)
379+
connection.execute(text(drop_view_cherrypicked_samples))
377380
print("*** Dropping table ROLES ***")
378-
connection.execute(drop_table_roles)
381+
connection.execute(text(drop_table_roles))
379382
print("*** Dropping table ROLE TYPES ***")
380-
connection.execute(drop_table_role_types)
383+
connection.execute(text(drop_table_role_types))
381384
print("*** Dropping table EVENTS ***")
382-
connection.execute(drop_table_events)
385+
connection.execute(text(drop_table_events))
383386
print("*** Dropping table EVENT TYPES ***")
384-
connection.execute(drop_table_event_types)
387+
connection.execute(text(drop_table_event_types))
385388
print("*** Dropping table SUBJECT ***")
386-
connection.execute(drop_table_subjects)
389+
connection.execute(text(drop_table_subjects))
387390
print("*** Dropping table SUBJECT TYPES ***")
388-
connection.execute(drop_table_subject_types)
391+
connection.execute(text(drop_table_subject_types))
389392

390393
print("*** Creating table SUBJECT TYPES ***")
391-
connection.execute(create_table_subject_types)
394+
connection.execute(text(create_table_subject_types))
392395
print("*** Creating table SUBJECTS ***")
393-
connection.execute(create_table_subjects)
396+
connection.execute(text(create_table_subjects))
394397
print("*** Creating table EVENT TYPES ***")
395-
connection.execute(create_table_event_types)
398+
connection.execute(text(create_table_event_types))
396399
print("*** Creating table EVENTS ***")
397-
connection.execute(create_table_events)
400+
connection.execute(text(create_table_events))
398401
print("*** Creating table ROLE TYPES ***")
399-
connection.execute(create_table_role_types)
402+
connection.execute(text(create_table_role_types))
400403
print("*** Creating table ROLES ***")
401-
connection.execute(create_table_roles)
404+
connection.execute(text(create_table_roles))
402405
print("*** Creating view CHERRYPICKED SAMPLES ***")
403-
connection.execute(create_cherrypicked_samples_view)
406+
connection.execute(text(create_cherrypicked_samples_view))
404407

405408
print("Done")

0 commit comments

Comments
 (0)