diff options
Diffstat (limited to 'lib/sqlalchemy/schema.py')
| -rw-r--r-- | lib/sqlalchemy/schema.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 0d626397f..44dcb5755 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -1336,5 +1336,21 @@ class SchemaVisitor(visitors.ClauseVisitor): def _bind_or_error(schemaitem): bind = schemaitem.bind if not bind: - raise exceptions.InvalidRequestError("This SchemaItem is not connected to any Engine or Connection.") - return bind
\ No newline at end of file + name = schemaitem.__class__.__name__ + label = getattr(schemaitem, 'fullname', + getattr(schemaitem, 'name', None)) + if label: + item = '%s %r' % (name, label) + else: + item = name + if isinstance(schemaitem, MetaData): + bindable = "the %s's .bind" % name + else: + bindable = "this %s's .metadata.bind" % name + + msg = ('The %s is not bound to an Engine or Connection. ' + 'Execution can not proceed without a database to execute ' + 'against. Either execute with an explicit connection or ' + 'assign %s to enable implicit execution.') % (item, bindable) + raise exceptions.UnboundExecutionError(msg) + return bind |
