Skip to content

Bump sqlalchemy from 1.4.46 to 2.0.1 #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pyodbc = "~=4.0"
python-dotenv = "~=1.0"
requests = "~=2.28"
slackclient = "~=2.9"
sqlalchemy = "~=1.4"
sqlalchemy = "~=2.0"
pymongo = "~=4.3.3"

[requires]
Expand Down
96 changes: 52 additions & 44 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lighthouse/helpers/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def get_table(sql_engine: Engine, table_name: str) -> Table:
Returns:
Table: a SQLAlchemy Table object.
"""
metadata = MetaData(sql_engine)
metadata = MetaData()

metadata.reflect()
metadata.reflect(sql_engine)

return metadata.tables[table_name]
51 changes: 27 additions & 24 deletions setup_test_db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# flake8: noqa
from sqlalchemy import text

import lighthouse.config.test as config
from lighthouse.helpers.mysql import create_mysql_connection_engine

Expand All @@ -11,6 +13,7 @@
create_db = """
CREATE DATABASE IF NOT EXISTS `unified_warehouse_test` /*!40100 DEFAULT CHARACTER SET latin1 */;
"""

drop_table_lh_sample = """
DROP TABLE IF EXISTS `unified_warehouse_test`.`lighthouse_sample`;
"""
Expand Down Expand Up @@ -186,25 +189,25 @@
"""

with sql_engine.connect() as connection:
connection.execute(create_db)
connection.execute(text(create_db))

print("*** Dropping table LIGHTHOUSE SAMPLE ***")
connection.execute(drop_table_lh_sample)
connection.execute(text(drop_table_lh_sample))
print("*** Dropping table STOCK RESOURCE ***")
connection.execute(drop_table_stock_resource)
connection.execute(text(drop_table_stock_resource))
print("*** Dropping table STUDY ***")
connection.execute(drop_table_study)
connection.execute(text(drop_table_study))
print("*** Dropping table SAMPLE ***")
connection.execute(drop_table_sample)
connection.execute(text(drop_table_sample))

print("*** Creating table SAMPLE ***")
connection.execute(create_table_sample)
connection.execute(text(create_table_sample))
print("*** Creating table STUDY ***")
connection.execute(create_table_study)
connection.execute(text(create_table_study))
print("*** Creating table STOCK RESOURCE ***")
connection.execute(create_table_stock_resource)
connection.execute(text(create_table_stock_resource))
print("*** Creating table LIGHTHOUSE SAMPLE ***")
connection.execute(create_table_lh_sample)
connection.execute(text(create_table_lh_sample))

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

Expand Down Expand Up @@ -350,36 +353,36 @@


with sql_engine.connect() as connection:
connection.execute(create_db)
connection.execute(text(create_db))

print("*** Dropping table ROLES ***")
connection.execute(drop_table_roles)
connection.execute(text(drop_table_roles))
print("*** Dropping table ROLE TYPES ***")
connection.execute(drop_table_role_types)
connection.execute(text(drop_table_role_types))
print("*** Dropping table EVENTS ***")
connection.execute(drop_table_events)
connection.execute(text(drop_table_events))
print("*** Dropping table EVENT TYPES ***")
connection.execute(drop_table_event_types)
connection.execute(text(drop_table_event_types))
print("*** Dropping table SUBJECT ***")
connection.execute(drop_table_subjects)
connection.execute(text(drop_table_subjects))
print("*** Dropping table SUBJECT TYPES ***")
connection.execute(drop_table_subject_types)
connection.execute(text(drop_table_subject_types))
print("*** Dropping view CHERRYPICKED SAMPLES ***")
connection.execute(drop_view_cherrypicked_samples)
connection.execute(text(drop_view_cherrypicked_samples))

print("*** Creating table SUBJECT TYPES ***")
connection.execute(create_table_subject_types)
connection.execute(text(create_table_subject_types))
print("*** Creating table SUBJECTS ***")
connection.execute(create_table_subjects)
connection.execute(text(create_table_subjects))
print("*** Creating table EVENT TYPES ***")
connection.execute(create_table_event_types)
connection.execute(text(create_table_event_types))
print("*** Creating table EVENTS ***")
connection.execute(create_table_events)
connection.execute(text(create_table_events))
print("*** Creating table ROLE TYPES ***")
connection.execute(create_table_role_types)
connection.execute(text(create_table_role_types))
print("*** Creating table ROLES ***")
connection.execute(create_table_roles)
connection.execute(text(create_table_roles))
print("*** Creating view CHERRYPICKED SAMPLES ***")
connection.execute(create_cherrypicked_samples_view)
connection.execute(text(create_cherrypicked_samples_view))

print("Done")