summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/sqlsoup.py
diff options
context:
space:
mode:
authorJonathan Ellis <jbellis@gmail.com>2009-03-09 21:24:43 +0000
committerJonathan Ellis <jbellis@gmail.com>2009-03-09 21:24:43 +0000
commita4ee98fe66248d2550d818c8027f6c1256c9bc98 (patch)
tree16eebcfa2ad8203e6c7f0292d6ade2da5fbaa7d4 /lib/sqlalchemy/ext/sqlsoup.py
parent68ee348d36c7df8ccdaf57c3ca6da03e905590bc (diff)
downloadsqlalchemy-a4ee98fe66248d2550d818c8027f6c1256c9bc98.tar.gz
add schema to entity method
Diffstat (limited to 'lib/sqlalchemy/ext/sqlsoup.py')
-rw-r--r--lib/sqlalchemy/ext/sqlsoup.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/sqlsoup.py b/lib/sqlalchemy/ext/sqlsoup.py
index f2754793b..b3f2de743 100644
--- a/lib/sqlalchemy/ext/sqlsoup.py
+++ b/lib/sqlalchemy/ext/sqlsoup.py
@@ -286,6 +286,9 @@ You can load a table whose name is specified at runtime with the entity() method
>>> db.entity(tablename) == db.loans
True
+entity() also takes an optional schema argument. If none is specified, the
+default schema is used.
+
Extra tests
===========
@@ -537,11 +540,11 @@ class SqlSoup:
j = join(*args, **kwargs)
return self.map(j)
- def entity(self, attr):
+ def entity(self, attr, schema=None):
try:
t = self._cache[attr]
except KeyError:
- table = Table(attr, self._metadata, autoload=True, schema=self.schema)
+ table = Table(attr, self._metadata, autoload=True, schema=schema or self.schema)
if not table.primary_key.columns:
raise PKNotFoundError('table %r does not have a primary key defined [columns: %s]' % (attr, ','.join(table.c.keys())))
if table.columns: