On Aug 9, 2009, at 1:24 PM, allen.fowler wrote:
> So, just to clarify: > > At this point in time, can SQLAlchemy be used to define and query > simple VIEWs in a database agnostic manner? > > And if not, is this a feature that is slated for addition any time > soon? CREATE VIEW is almost identical across backends and can be achieved like this: someselect = select([table.c.foo, table.c.bar]) eng = create_engine('...') eng.execute("CREATE VIEW foobar AS %s" % someselect.compile(eng)) then build yourself a Table with columns representing the view. its easy enough to build a CreateView DDL() construct in 0.6 to do this, i.e. eng.execute(CreateView("myview", someselect)) I'd consult the sqlalchemy.ext.compiler docs for how to do this. as a builtin I'm uncomfortable since it implies adding a View() object to schema which raises lots of thorny questions like "what if I construct an INSERT against the view ?" " what about materialized views?" , "what if I join my View() to the underlying Table() ?" etc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---