On May 14, 2012, at 10:33 AM, Edward Welbourne wrote:
>
> Most of SQL is sufficiently standardised to permit writing portable code
> to explore a database - provided access compatible with PEP 249 is
> available - without need to know details of the SQL implementation; so
> it would be nice if some future version of the DB API were to specify a
> standard method, of connection objects, that can be used to obtain the
> list of tables available via the connection.
while not part of PEP 249 or probably appropriate as part of the "standard",
portable schema information is one of the goals of SQLAlchemy, which it
provides via the Inspector interface. For example, the listing of table names
in the default schema is as follows:
from sqlalchemy import create_engine
from sqlalchemy.engine.reflection import Inspector
engine = create_engine("mydialect://user:pass@host/dbname")
insp = Inspector.from_engine(engine)
print insp.get_table_names()
SQLAlchemy implements a sizable array of database "dialects", each of which
perform the requisite queries to get at various bits of schema detail,
including the ability to represent a full series of tables as navigable Python
constructs.
_______________________________________________
DB-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/db-sig