HI, I m currently trying to vertical partition my database and I have split it into two groups of tables (say { documents, table1, table2 } and { table3 }. So I have
s_engine = create_engine(t_database_string)#, echo=True) #echo="debug")#, echo=True) t_engine = create_engine(t_database_string) Base = declarative_base() metadata = Base.metadata documents = Table("documents', metadata, Column("document_id", Integer, primary_key = True), } table1 = Table("table1", metadata, Column("interval_id", Integer, primary_key=True), Column("document_id", Integer, ForeignKey("documents.document_id")), ) table3 = Table("table3", metadata, Column("foo_id", Integer, primary_key = True), ) table2 = Table("table2", metadata, Column("id", Integer, primary_key = True), Column("interval_id", Integer, ForeignKey("table1.interval__id")) Column("foo_id", Integer, ForeignKey("table3.foo_id")) ) secondary = table1.join(table2, onclause=table1.c.interval_id==table2.c.interval_id).alias("spe_join") table3.create(bind=t_engine) ........ etc mapper(Foo, table3) mapper(Document, documents_table, properties={ "foos":relation(Foo, primaryjoin=documents_table.c.document_id == secondary.c.intervals_document_id, secondaryjoin=secondary.c.table2_foo_id == table3.c.foo_id, viewonly = True, secondary=secondary) }) session = sessionmaker(binds={Document:s_engine, Foo:t_engine}) however what happens is that it complains about the foos relation in that it says that sqlalchemy.exc.ArgumentError: Could not determine relation direction for secondaryjoin condition 'spe_join.table2_foo_id = foo.foo_id', on relation Document.foos. Specify the foreign_keys argument to indicate which columns on the relation are foreign. When I had all the tables in the same database I had no problems involving having to specify foreign keys. What does SQLalchemy do it the background here? Is my problem that it doesnt know that table3 is accessed via the t_engine. How can I make it explicitly know this here? I have tried using different metadata bindings but to no good. Any pointers/help would be greatly appreciated? Nathan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---