diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-10-02 18:05:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-10-02 18:05:19 -0400 |
commit | 15442ed1f41f1e9b2b1199fa52966c6151ec2592 (patch) | |
tree | c50a44d33f5b016daae4ad88b56bb0e161493e57 /lib/sqlalchemy/schema.py | |
parent | 19d5287d833110507d8ed7b64d31871f67d3f171 (diff) | |
download | sqlalchemy-15442ed1f41f1e9b2b1199fa52966c6151ec2592.tar.gz |
- added "views=True" option to metadata.reflect(),
will add the list of available views to those
being reflected. [ticket:1936]
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r-- | lib/sqlalchemy/schema.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 59f9fae7f..069e58ced 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -2010,7 +2010,7 @@ class MetaData(SchemaItem): from sqlalchemy.sql.util import sort_tables return sort_tables(self.tables.itervalues()) - def reflect(self, bind=None, schema=None, only=None): + def reflect(self, bind=None, schema=None, views=False, only=None): """Load all available table definitions from the database. Automatically creates ``Table`` entries in this ``MetaData`` for any @@ -2026,7 +2026,10 @@ class MetaData(SchemaItem): :param schema: Optional, query and reflect tables from an alterate schema. - + + :param views: + If True, also reflect views. + :param only: Optional. Load only a sub-set of available named tables. May be specified as a sequence of names or a callable. @@ -2055,6 +2058,11 @@ class MetaData(SchemaItem): available = util.OrderedSet(bind.engine.table_names(schema, connection=conn)) + if views: + available.update( + bind.dialect.get_view_names(conn or bind, schema) + ) + current = set(self.tables.iterkeys()) if only is None: |