Commits

Marcin Kuzminski  committed 90429b2

show message for pylons template where to explicitly define engine for usage in migrations

  • Participants
  • Parent commits fd170e0

Comments (0)

Files changed (1)

File alembic/templates/pylons/env.py

 from alembic import context
 from paste.deploy import loadapp
 from logging.config import fileConfig
+from sqlalchemy.engine.base import Engine
 
 
 try:
     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