From: Marcin Kuzminski Date: Wed, 8 Feb 2012 17:42:38 +0000 (+0200) Subject: show message for pylons template where to explicitly define engine for usage in migra... X-Git-Tag: rel_0_2_2~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8127da51c50d7ebb61966cb38d55c0adaa2f5689;p=thirdparty%2Fsqlalchemy%2Falembic.git show message for pylons template where to explicitly define engine for usage in migrations --- diff --git a/alembic/templates/pylons/env.py b/alembic/templates/pylons/env.py index 90b65d01..e25d64dc 100644 --- a/alembic/templates/pylons/env.py +++ b/alembic/templates/pylons/env.py @@ -7,6 +7,7 @@ be loaded from there. from alembic import context from paste.deploy import loadapp from logging.config import fileConfig +from sqlalchemy.engine.base import Engine try: @@ -57,14 +58,17 @@ def run_migrations_online(): and associate a connection with the context. """ - - if hasattr(meta, 'engine'): - connection = meta.engine.connect() - elif hasattr(meta, 'Base'): - connection = meta.Base.metadata.bind.connect() + # specify here how the engine is acquired + # engine = meta.engine + raise NotImplementedError("Please specify engine connectivity here") + + if isintance(engine, Engine): + connection = engine.connect() else: - raise Exception(('Unable to fetch connection from meta %s' - 'Try to define engine or Base in meta file') % meta) + raise Exception( + 'Expected engine instance got %s instead' % type(engine) + ) + context.configure( connection=connection, target_metadata=target_metadata