occurs error when dbsync with sqlalchemy backend

Bug #2036588 reported by frankming
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
taskflow
New
Undecided
Unassigned

Bug Description

Hi guys,
  with latest taskflow(5.4.0), SQLAlchemy(2.0.21) and alembic(1.12.0), I tried to dbsync by using SQLAlchemyBackend.get_connection().upgrade() method. However, it raised AttributeError: 'Connection' object has no attribute 'connect' when I executed conn.upgrade() statement. It seems a problem. Codes and error are as follows.

====================
reproduce process
====================

python
>>> from taskflow.persistence.backends.impl_sqlalchemy import SQLAlchemyBackend
>>> conf={'connection': 'mysql+pymysql://test:123456@127.0.0.1:3306/test'}
>>> conn=SQLAlchemyBackend(conf).get_connection()
>>> conn.upgrade()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/taskflow/persistence/backends/impl_sqlalchemy.py", line 405, in upgrade
    migration.db_sync(conn)
  File "/usr/local/lib/python3.9/site-packages/taskflow/persistence/backends/sqlalchemy/migration.py", line 33, in db_sync
    command.upgrade(cfg, revision)
  File "/usr/local/lib/python3.9/site-packages/alembic/command.py", line 399, in upgrade
    script.run_env()
  File "/usr/local/lib/python3.9/site-packages/alembic/script/base.py", line 578, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 109, in load_module_py
    spec.loader.exec_module(module) # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/local/lib/python3.9/site-packages/taskflow/persistence/backends/sqlalchemy/alembic/env.py", line 78, in <module>
    run_migrations_online()
  File "/usr/local/lib/python3.9/site-packages/taskflow/persistence/backends/sqlalchemy/alembic/env.py", line 68, in run_migrations_online
    with connectable.connect() as connection:
AttributeError: 'Connection' object has no attribute 'connect'

Revision history for this message
martin lee (martinder) wrote :

I have met the same issue, it's still there. I have changed the source code, it works:
 with connectable.connect() as connection => with connectable.engine.connect() as connection

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.