diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-07-31 00:19:23 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-07-31 00:19:23 +0000 |
commit | 04e8a839b4bc6a612b88ff793755865591b48ac4 (patch) | |
tree | f6993291f389525ad3b0fed6e1d370a8c66933a3 /lib/sqlalchemy/engine/base.py | |
parent | a7e81eda731ddf11994ea77ac556168388c9285b (diff) | |
download | sqlalchemy-04e8a839b4bc6a612b88ff793755865591b48ac4.tar.gz |
MetaData can now reflect() all tables in the database en-masse thanks to table_names().
table_names changed to accept an explicit connection
ThreadLocalMetaData constructor now takes no arguments. If case_sensitive is needed in a multi-bind context, move it to Table or subclass TLMD to force it.
Banished **kwargs from MetaData
Lots of class doc and docstring improvements around MetaData and TLMD.
Some engine->bind internal naming updates + reorg in schema.
MySQL table_names now return Unicode. (Also, a unicode reflect() unit test is needed.)
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 5e6c74c91..642eeac62 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1028,8 +1028,21 @@ class Engine(Connectable): return Connection(self, close_with_result=close_with_result, **kwargs) - def table_names(self, schema=None): - conn = self.contextual_connect() + def table_names(self, schema=None, connection=None): + """Return a list of all table names available in the database. + + schema: + Optional, retrieve names from a non-default schema. + + connection: + Optional, use a specified connection. Default is the + ``contextual_connect`` for this ``Engine``. + """ + + if connection is None: + conn = self.contextual_connect() + else: + conn = connection if not schema: try: schema = self.dialect.get_default_schema_name(conn) @@ -1038,7 +1051,8 @@ class Engine(Connectable): try: return self.dialect.table_names(conn, schema) finally: - conn.close() + if connection is None: + conn.close() def reflecttable(self, table, connection=None, include_columns=None): """Given a Table object, reflects its columns and properties from the database.""" |