"Mike Bayer" <mike_not_on_goo...@zzzcomputing.com> writes:

> can you add these assertions to env.py?
>
> with context.begin_transaction():
>     assert not context.get_context()._in_external_transaction
>     assert not connection.in_transaction()
>     context.run_migrations()
>
> that's the condition necessary for begin_transaction() to call
> commit() at the end.

With those in place, the first one fails with this traceback:

16:56:36 [I] sqlalchemy.engine.Engine: BEGIN (implicit)
16:56:36 [I] sqlalchemy.engine.Engine: PRAGMA foreign_keys=OFF
16:56:36 [I] sqlalchemy.engine.Engine: [raw sql] ()
16:56:36 [I] sqlalchemy.engine.Engine: ROLLBACK
Traceback (most recent call last):
  File "/home/lele/wip/sol5/env/bin/soladmin", line 33, in <module>
    sys.exit(load_entry_point('SoL', 'console_scripts', 'soladmin')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lele/wip/sol5/src/sol/scripts/admin.py", line 640, in main
    sys.exit((args.func(args) or 0) if hasattr(args, 'func') else 0)
              ^^^^^^^^^^^^^^^
  File "/home/lele/wip/sol5/src/sol/scripts/admin.py", line 195, in upgrade_db
    command.upgrade(cfg, "head")
  File 
"/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/command.py", line 
378, in upgrade
    script.run_env()
  File 
"/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/script/base.py", 
line 569, in run_env
    util.load_python_file(self.dir, "env.py")
  File 
"/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/util/pyfiles.py", 
line 94, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File 
"/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/util/pyfiles.py", 
line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/lele/wip/sol5/alembic/env.py", line 88, in <module>
    run_migrations_online()
  File "/home/lele/wip/sol5/alembic/env.py", line 80, in run_migrations_online
    assert not context.get_context()._in_external_transaction
AssertionError

That "soladmin" launcher is the CLI tool to manage the instance, that in
this case is just a thin wrapper around alembic.upgrade():
https://gitlab.com/metapensiero/SoL/-/blob/master/src/sol/scripts/admin.py#L173

And sorry for not having mentioned that another different cog I'm trying
out is running it with Python 3.11.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  |                 -- Fortunato Depero, 1929.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/878ri3eq4g.fsf%40metapensiero.it.

Reply via email to