|
1 | 1 | # flake8: noqa
|
| 2 | +from sqlalchemy import text |
| 3 | + |
2 | 4 | import crawler.config.test as config
|
3 | 5 | from crawler.db.mysql import create_mysql_connection_engine
|
4 | 6 |
|
|
11 | 13 | create_db = """
|
12 | 14 | CREATE DATABASE IF NOT EXISTS `unified_warehouse_test` /*!40100 DEFAULT CHARACTER SET latin1 */;
|
13 | 15 | """
|
| 16 | + |
14 | 17 | drop_table_lh_sample = """
|
15 | 18 | DROP TABLE IF EXISTS `unified_warehouse_test`.`lighthouse_sample`;
|
16 | 19 | """
|
|
204 | 207 | """
|
205 | 208 |
|
206 | 209 | with sql_engine.connect() as connection:
|
207 |
| - connection.execute(create_db) |
| 210 | + connection.execute(text(create_db)) |
208 | 211 |
|
209 | 212 | print("*** Dropping table LIGHTHOUSE SAMPLE ***")
|
210 |
| - connection.execute(drop_table_lh_sample) |
| 213 | + connection.execute(text(drop_table_lh_sample)) |
211 | 214 | print("*** Dropping table STOCK RESOURCE ***")
|
212 |
| - connection.execute(drop_table_stock_resource) |
| 215 | + connection.execute(text(drop_table_stock_resource)) |
213 | 216 | print("*** Dropping table STUDY ***")
|
214 |
| - connection.execute(drop_table_study) |
| 217 | + connection.execute(text(drop_table_study)) |
215 | 218 | print("*** Dropping table SAMPLE ***")
|
216 |
| - connection.execute(drop_table_sample) |
| 219 | + connection.execute(text(drop_table_sample)) |
217 | 220 |
|
218 | 221 | print("*** Creating table SAMPLE ***")
|
219 |
| - connection.execute(create_table_sample) |
| 222 | + connection.execute(text(create_table_sample)) |
220 | 223 | print("*** Creating table STUDY ***")
|
221 |
| - connection.execute(create_table_study) |
| 224 | + connection.execute(text(create_table_study)) |
222 | 225 | print("*** Creating table STOCK RESOURCE ***")
|
223 |
| - connection.execute(create_table_stock_resource) |
| 226 | + connection.execute(text(create_table_stock_resource)) |
224 | 227 | print("*** Creating table LIGHTHOUSE SAMPLE ***")
|
225 |
| - connection.execute(create_table_lh_sample) |
| 228 | + connection.execute(text(create_table_lh_sample)) |
226 | 229 |
|
227 | 230 | print("Initialising the test MySQL events warehouse database")
|
228 | 231 |
|
|
370 | 373 | """
|
371 | 374 |
|
372 | 375 | with sql_engine.connect() as connection:
|
373 |
| - connection.execute(create_db) |
| 376 | + connection.execute(text(create_db)) |
374 | 377 |
|
375 | 378 | print("*** Dropping view CHERRYPICKED SAMPLES ***")
|
376 |
| - connection.execute(drop_view_cherrypicked_samples) |
| 379 | + connection.execute(text(drop_view_cherrypicked_samples)) |
377 | 380 | print("*** Dropping table ROLES ***")
|
378 |
| - connection.execute(drop_table_roles) |
| 381 | + connection.execute(text(drop_table_roles)) |
379 | 382 | print("*** Dropping table ROLE TYPES ***")
|
380 |
| - connection.execute(drop_table_role_types) |
| 383 | + connection.execute(text(drop_table_role_types)) |
381 | 384 | print("*** Dropping table EVENTS ***")
|
382 |
| - connection.execute(drop_table_events) |
| 385 | + connection.execute(text(drop_table_events)) |
383 | 386 | print("*** Dropping table EVENT TYPES ***")
|
384 |
| - connection.execute(drop_table_event_types) |
| 387 | + connection.execute(text(drop_table_event_types)) |
385 | 388 | print("*** Dropping table SUBJECT ***")
|
386 |
| - connection.execute(drop_table_subjects) |
| 389 | + connection.execute(text(drop_table_subjects)) |
387 | 390 | print("*** Dropping table SUBJECT TYPES ***")
|
388 |
| - connection.execute(drop_table_subject_types) |
| 391 | + connection.execute(text(drop_table_subject_types)) |
389 | 392 |
|
390 | 393 | print("*** Creating table SUBJECT TYPES ***")
|
391 |
| - connection.execute(create_table_subject_types) |
| 394 | + connection.execute(text(create_table_subject_types)) |
392 | 395 | print("*** Creating table SUBJECTS ***")
|
393 |
| - connection.execute(create_table_subjects) |
| 396 | + connection.execute(text(create_table_subjects)) |
394 | 397 | print("*** Creating table EVENT TYPES ***")
|
395 |
| - connection.execute(create_table_event_types) |
| 398 | + connection.execute(text(create_table_event_types)) |
396 | 399 | print("*** Creating table EVENTS ***")
|
397 |
| - connection.execute(create_table_events) |
| 400 | + connection.execute(text(create_table_events)) |
398 | 401 | print("*** Creating table ROLE TYPES ***")
|
399 |
| - connection.execute(create_table_role_types) |
| 402 | + connection.execute(text(create_table_role_types)) |
400 | 403 | print("*** Creating table ROLES ***")
|
401 |
| - connection.execute(create_table_roles) |
| 404 | + connection.execute(text(create_table_roles)) |
402 | 405 | print("*** Creating view CHERRYPICKED SAMPLES ***")
|
403 |
| - connection.execute(create_cherrypicked_samples_view) |
| 406 | + connection.execute(text(create_cherrypicked_samples_view)) |
404 | 407 |
|
405 | 408 | print("Done")
|
0 commit comments