summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/automap.py
diff options
context:
space:
mode:
authorJosh Marlow <joshmarlow@gmail.com>2016-04-11 23:16:12 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-06-02 14:00:13 -0400
commitcafebe160434973d07b1fa3412064c2870d781f2 (patch)
tree64e1391c0ef259596c5245e3920dced75fb1dd61 /lib/sqlalchemy/ext/automap.py
parent31699bd1866bbfc36f1501e5e1b54d3c06cf3b4c (diff)
downloadsqlalchemy-cafebe160434973d07b1fa3412064c2870d781f2.tar.gz
Add schema argument to AutomapBase.prepare()
This allows automap to reflect tables from a schema other than the default without the need to resort to calling MetaData.reflect directly. Change-Id: Ie73cb113bd6d115555c09c5efc33d27ad2c9c512 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/237
Diffstat (limited to 'lib/sqlalchemy/ext/automap.py')
-rw-r--r--lib/sqlalchemy/ext/automap.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py
index bb1c5da3d..23ad56b76 100644
--- a/lib/sqlalchemy/ext/automap.py
+++ b/lib/sqlalchemy/ext/automap.py
@@ -695,6 +695,7 @@ class AutomapBase(object):
cls,
engine=None,
reflect=False,
+ schema=None,
classname_for_table=classname_for_table,
collection_class=list,
name_for_scalar_relationship=name_for_scalar_relationship,
@@ -735,10 +736,19 @@ class AutomapBase(object):
when a new :func:`.relationship` object is created that represents a
collection. Defaults to ``list``.
+ :param schema: When present in conjunction with the
+ :paramref:`.AutomapBase.prepare.reflect` flag, is passed to
+ :meth:`.MetaData.reflect` to indicate the primary schema where tables
+ should be reflected from. When omitted, the default schema in use
+ by the database connection is used.
+
+ .. versionadded:: 1.1
+
"""
if reflect:
cls.metadata.reflect(
engine,
+ schema=schema,
extend_existing=True,
autoload_replace=False
)