i guess 'emulate' was the wrong word. i should have said 'design'. i do want the postgres inherits. i would like sqlalchemy to create these tables, and to tell postgres to use real inheritance.
when the parent and child tables are created and filled with data, the parent table should be "empty", in that it holds no real data. postgres is just smart enough to use the constraints to redirect the query to the child tables. you set up the insert trigger so that the data is inserted into the child tables, and the parent never holds anything. but you can still query and insert against the parent table. i never want to query against a child table. i only want to query the parent, which means on the sqlalchemy side, i never want a child table/ object. i am aware that this feature/ability is very much a postgres-specific thing, and just may not be doable by sqlalchemy. i've yet to find a working example of this, so i assume it's just not possible. thanks a lot for the reply. jas On Jul 22, 9:30 am, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Jul 22, 2011, at 8:49 AM, jasonmclose wrote: > > > > > my desire is to emulate this with sqlalchemy, > > Ok "emulate", meaning, you no longer want to use Postgresql INHERITS and want > SQLA to deal with the multiple tables ? Assuming I haven't forgotten how > INHERITS works (I've not used it myself), concrete table inheritance is most > similar here, i.e. that each table maintains all columns. It's an awkward > mode of usage as each class needs to query from a different table, and to > query all classes at once requires a UNION. Docs are > athttp://www.sqlalchemy.org/docs/orm/inheritance.html#concrete-table-in.... > > Concrete is also difficult to map with declarative at the moment, if you're > using a polymorphic_union, since the selectable needs to be known up front > and needs the related tables in order to be constructed - theres a recipe > athttp://www.sqlalchemy.org/trac/wiki/UsageRecipes/DeclarativeAbstractC...which > may help. > > Joined or single table inheritance are much easier to use patterns with > SQLAlchemy as well as other ORMs that do inheritance, they're described in > those docs as well. > > For the relationship with concrete, its again tricky (and with single/joined, > quite simple). A discussion of this is > here:http://www.sqlalchemy.org/docs/orm/inheritance.html#relationships-wit.... > Basically every table has to have the foreign key back to the referenced > table, as well as its own relationship(). > > If you wanted to map directly on top of the PG INHERITS structure, you'd > again use concrete inheritance, map to each table explicitly, and you'd get > the selection of polymorphic objects for free using PG's built in behavior. -- 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.