To my knowledge, there doesn't exist a tool to extract schema 
information from a database with a database independent API.  SA does 
this to some extent by providing "table_names" and "reflectable" methods 
on it's Engine class, but I think it would be nice to have something 
more comprehensive and fine grained.

It seems to me that ORM is only a part of SA's function.  I've used SA's 
connection, cursor (ResultProxy) and SQL abstractions without ORM as a 
kind of higher level DBAPI with good results.  I think that a schema 
information API would fit well into SA's theme.  The implementation 
could make use of the non-ORM features as well as providing for some 
other features like table reflection.

How would it fit in?  I think it should be usable without requiring the 
use of other SA facilities.  Maybe like this:

*****************************************************************

import sqlalchemy as sa
from sqlalchemy.database import dbinfo

engine = sa.create_engine('postgres:///')
# or a dbapi connection

# return list of schema names
schema_names = dbinfo.getSchemaNames(engine)
# return list of table names
table_names = dbinfo.getTableNames(engine, schema_name='public')
# return list of view names
view_names = dbinfo.getViewNames(engine, schema_name='public')
# return the SQL statement required to get view names (no connectable)
view_names = dbinfo.getViewNames(schema_name='public')

# Also like this.

info = dblib.PostgresInfoFetcher(engine)
print info.getSchemaNames()
print info.getConstraintInfo(table_name='t1', schema_name='s1')
# Returns the SQL.
print info.getConstraintInfo(table_name='t1', schema_name='s1', 

                              return_statement=True)

*****************************************************************

Note that a method can return records or an SQL statement.  I have a 
basic implementation of this based on information_schema that works with 
Postgresql and MSSQL (and maybe Oracle).


I'd like to get some opinions on this before going any further.  Is it 
needed?  If so, how should it be implemented?  Would it be good as a 
part of SA or should it be separate?

--Randall


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to