DOCKER + Pyramid app + SQLAlchemy + Migration(Alembic)

564 views
Skip to first unread message

Mário Idival

unread,
Jul 6, 2015, 5:31:58 PM7/6/15
to sqlalchem...@googlegroups.com
Hello guys, someone using this stack to development?
Has anyone had problems with alembic using docker? (separated PostgreSQL and Python container)

j...@inklesspen.com

unread,
Jul 7, 2015, 11:17:56 AM7/7/15
to sqlalchem...@googlegroups.com
On Monday, July 6, 2015 at 5:31:58 PM UTC-4, Mário Idival wrote:
Hello guys, someone using this stack to development?
Has anyone had problems with alembic using docker? (separated PostgreSQL and Python container)

I have been working on exactly this problem in recent days (pyramid and alembic in docker). The main issue is that the PostgreSQL connection information needs to be taken from the environment, not an INI file.

I will be posting my work in a Github repo soonish (in a week or two), but until then, here is my suggestion:

There is actually no need for the sqlalchemy url to be in the ini file; nothing in Alembic's code requires it. It is used in two places in the generated env.py: https://bitbucket.org/zzzeek/alembic/src/a294f8cc3f2e5fc2cad048bc4ce27c57554e2688/alembic/templates/generic/env.py?at=master

run_migrations_offline pulls the url out of the INI directly; you can instead construct it from the information in the environment (or skip using run_migrations_offline entirely)
run_migrations_online uses engine_from_config with the INI config. You could use the config.set_main_option method to set the url into the config (after constructing it from the environment variables), or use a different way of getting a sqlalchemy engine.

Mário Idival

unread,
Jul 8, 2015, 11:31:51 PM7/8/15
to sqlalchem...@googlegroups.com

I already tried everything and nothing is working :(
Reply all
Reply to author
Forward
0 new messages