On Jul 22, 2011, at 11:26 AM, jasonmclose wrote: > 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.
Should be doable. Map Parent against the "parent" table, map each Child against Parent, without no Table for each child, using single table inheritance. Single table inheritance means all subclasses come from the same table. The fact that PG INHERITS is being used is strictly a storage implementation not revealed to the client side. This is the "right" way to use PG INHERITS, as a transparent sharding mechanism. As far as each child table itself with the INHERITS keyword, to emit the CREATE TABLE for those I'd use a DDL() construct or just emit the "CREATE" statement via execute(). It's mostly a one liner as you aren't adding any new columns to these child tables. There would be no Table object on the SQLAlchemy side for these. If I have time (of which there hasnt been a lot lately) I'll try to put an example on the wiki. -- 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.