From 8127da51c50d7ebb61966cb38d55c0adaa2f5689 Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Wed, 8 Feb 2012 19:42:38 +0200 Subject: [PATCH] show message for pylons template where to explicitly define engine for usage in migrations --- alembic/templates/pylons/env.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 -- 2.47.2