Hi, I'm a fresh user of SQLA, and this is my first attempt to use it.
Based on the official tutorial example I created a many to many relation between two tables, but I have some issues with getting it working. It returns error "Could not determine join condition between parent/child tables on relation Protein_seed.pdb_entry. Specify a 'primaryjoin' expression. If this is a many-to-many relation, 'secondaryjoin' is needed as well." I don't know how to define secondary key, while my association table "homologues" is not declarative and doesn't have it's own primary key. Can anybody help, please? meta = MetaData() Base = declarative_base(metadata=meta) homologues = Table('Homologues', meta, Column('protein_seed_id', Integer, ForeignKey ('Proteins_seed.id')), Column('protein_putative_id', Integer, ForeignKey ('Proteins_putative.id')) ) class PDB(Base): __tablename__ = 'PDB' id = Column(Integer, primary_key=True) name = Column(String, nullable=False, unique=True) chain = Column(String, nullable=False) def __init__(self, name, chain): self.name = name self.chain = chain def __repr__(self): return "<PDB('%s', '%s')>" % (self.name, self.chain) class Protein_seed(Base): __tablename__ = 'Proteins_seed' id = Column(Integer, primary_key=True) name = Column(String, nullable=False) sequence = Column(String, nullable=False) length = Column(Integer, nullable=False) alignment = Column(String, nullable=False) pdb_id = Column(Integer, ForeignKey('PDB.id')) # many-to-one Protein_seed * 1 PDB pdb_entry = relation('PDB', secondary=homologues, backref=backref ('Proteins_seed'), primaryjoin=pdb_id == PDB.id) def __init__(self, name, sequence, length, alignment): self.name = name self.sequence = sequence self.length = length self.alignment = alignment def __repr__(self): return "<Protein_seed('%s', '%s', '%s', '%s')>" % (self.name, self.sequence, self.length, self.alignment) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---