The Painter Lab would like to use the newest version of SQLAlchemy, version 2.0, in our software. Since SQLAlchemy 2.0 introduces breaking changes from version 1.4, I had to make the following changes in order to pass the EntropyLab test suite:
Using with engine.connect() as connection: and connection.execute() instead of engine.execute().
Wrapping SQL statements in text().
Session.close_all() was replaced with sqlalchemy.orm.close_all_sessions() in version 2.0.
Branched connections are removed from SQLAlchemy 2.0, so I simplified code in the env.py files to just assume that config.attributes["connection"] is a connection, and to use that connection directly instead of branching. I am not very familiar with Alembic though, so this may have unintended consequences even though it passed the tests.
Pandas 1.x uses SQLAlchemy 1.4 for pandas.read_sql(), so I refactored the code to make the SQL request separately and convert it using pandas.DataFrame.
SQLAlchemy 2.0 appears to handle UUIDs differently (internally using UUID.hex to convert them to strings), so some changes needed to be made to UUIDs.
A few import paths changed in version 2.0, including for contextmanager and declarative_base.
The Painter Lab would like to use the newest version of SQLAlchemy, version 2.0, in our software. Since SQLAlchemy 2.0 introduces breaking changes from version 1.4, I had to make the following changes in order to pass the EntropyLab test suite:
with engine.connect() as connection:
andconnection.execute()
instead ofengine.execute()
.text()
.Session.close_all()
was replaced withsqlalchemy.orm.close_all_sessions()
in version 2.0.config.attributes["connection"]
is a connection, and to use that connection directly instead of branching. I am not very familiar with Alembic though, so this may have unintended consequences even though it passed the tests.pandas.read_sql()
, so I refactored the code to make the SQL request separately and convert it usingpandas.DataFrame
.contextmanager
anddeclarative_base
.