OK, it seems to work finally :)
Thanks to this 
http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#configuring-relations

On Feb 2, 2:03 pm, Piotrek Byzia <piotr.by...@gmail.com> wrote:
> 'Homologues' seems to work, but no luck with 'Interactions' where I
> get rid of 'id' and code below returns error on join conditions:
> What should be ForeignKey and relation in each of this classes? Too
> bad that there is a declarative model introduced in the tutorial but
> all more advanced examples are not.
>
> class Protein_putative(Base):
>     __tablename__ = 'Proteins_putative'
>
>     id = Column(Integer, primary_key=True)
>     name = Column(String, nullable=False, unique=True)
>     primary_accession_number = Column(String, nullable=False)
>     description = Column(String)
>     sequence = Column(String, nullable=False)
>     length = Column(Integer, nullable=False)
>     alignment = Column(String, nullable=False)
>     # interaction_id = Column(Integer, ForeignKey('Interactions.id'))
>
>     interaction_entry = relation('Interaction',
> backref='Proteins_putative')
>
> class Interaction(Base):
>     __tablename__ = 'Interactions'
>
>     # id = Column(Integer, primary_key=True)
>     seed_reaction = Column(String, nullable=False)
>     first_protein_putative_id = Column(Integer, ForeignKey
> ('Proteins_putative.id'), primary_key=True)
>     second_protein_putative_id = Column(Integer, ForeignKey
> ('Proteins_putative.id'), primary_key=True)
>     # corresponding_putative_id = Column(Integer, ForeignKey
> ('Interactions.id'))
>
>     corresponding_putative_entry = relation('Protein_putative',
> backref='Interactions')
>
> On Feb 1, 9:13 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
>
> > On Feb 1, 2009, at 3:24 PM, Piotrek Byzia wrote:
>
> > > Michael,
>
> > > Thanks for that hint!
> > > However, I still don't know how should I include association table
> > > 'homologues' relation :-(
>
> > > I sketched a schema of my 
> > > DB:http://flickr.com/photos/piotrbyzia/3244490067/
> > > and relevant code is under:http://pastie.org/376811
>
> > > The similar problem is with Interactions table - how should I define
> > > many-to-many relation there?
>
> > > SQLA seems pretty mature, but to be honest, I struggle to find one
> > > complete example to use as a boiler plate...
>
> > you should map your classes just like your tables are linked.    
> > Proteins_seed has a "putative" relation that joins to  
> > Proteins_putative via relation(Protein_putative,  
> > secondary=homologues),   Proteins_putative has a relation() to  
> > Interaction, which then has a further relation() to Proteins_putative  
> > again, etc.  Every table in your picture gets a mapped class except  
> > for homologues, every line gets a relation() except for the lines in  
> > and out of homologues which is encompassed by a single relation().
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to