> > > That ForeignKey definition looks wrong - it should point at a column, not > a class. I think you want: > > ForeignKey(parent.parent_id)
Interesting, thanks, in the case where I use the same 'Base' for both classes, that solves it. In PostgreSQL the column definition isn't required if the column name is the same in both tables. I thought I'd tried explicitly setting it in sqlalchemy, but I was probably doing that in the case with Base2 and not the plain Base. This is expected. The call to declarative_base() creates a registry for > classes that inherit from that Base. When you use strings instead of > classes in your relationships (as you do when creating childRelationship), > those strings are looked up in the registry to find the class that they > refer to. Because ‘child’ and ‘parent’ exist in different registries, > sqlalchemy can’t resolve the string. > Interesting. So if I have a separate file for each table, I have to make sure they all use the same Base. I can do that. Thank you very much for the quick, helpful, and interesting reply! +1 :-) etc. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.