Michael Bayer wrote: > > On Dec 17, 2008, at 6:36 AM, Diez B. Roggisch wrote: > >> Hi, >> >> we've got some function-based indices we currently create using plain >> text()-calls, like this: >> >> CREATE UNIQUE INDEX >> users_lower_email_index >> ON >> user_db.users (lower(email)); >> >> This works, but it would be nice to stay in the SA-world even with >> these >> indices. >> >> And for schema-evolution purposes, we utilize reflection to compare >> tables. >> Reflection does not not include indices like the above though. Or I >> missed >> them? >> >> If not, is there a way to add that to SA, maybe through a plugin? >> I'd be happy >> to contribute if this is seen as valuable addition, I must add >> though that >> because we solely use postgres, I won't be able to add support for >> anything >> beyond that - but maybe others would step up to integrate other >> engines. > > Randall Smith has been working on a schema inspection API which I > believe seeks to reflect a wider variety of constructs such as > indexes. His progress can be seen here: > > http://www.sqlalchemy.org/trac/browser/sqlalchemy/branches/reflection
Index support for Postgres was recently added to the trunk and I merged it into the reflection branch. You are welcome to check out the reflection branch and give it a go. You could do a quick check like so: import sqlalchemy as sa from sqlalchemy.engine.reflection import Inspector e = sa.create_engine('postgres:///yourdb') inspector = Inspector(e) print inspector.get_indexes('yourtable', schema='yourschema') In fact, I'd love to get some feedback, especially for the Inspector interface. Everything should work for Postgres. Currently the Inspector supports these methods and attributes: default_schema_name get_schema_names() get_table_names() get_view_names() get_columns() get_primary_keys() get_foreign_keys() get_indexes() Now is a good time for comments and requests for this interface. Keep in mind that it's meant to be useful for non-ORM apps. This is the commit log for the index support: r5520 | zzzeek | 2008-12-22 22:47:52 -0600 (Mon, 22 Dec 2008) | 5 lines - Added Index reflection support to Postgres, using a great patch we long neglected, submitted by Ken Kuhlman. [ticket:714] -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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---