Dear all,
I have to create an association object that have to relate elements of
the same table.
These are the table definition:
ligand_table = Table('ligand', metadata,
Column('id', types.Integer, primary_key=True),
Column('number', types.Integer, nullable=False),
Column('name', types.Unicode(4), nullable=False),
)
ligand_ligand_table = Table('ligand_ligand', metadata,
Column('ligand_id1', types.Integer,
ForeignKey('ligand.id'),primary_key=True),
Column('ligand_id2', types.Integer,
ForeignKey('ligand.id'),primary_key=True),
Column('interaction_id',types.Integer, ForeignKey('interaction.id')),
Column('interaction_type', types.Unicode(10), nullable=False),
Column('distance', types.Float, nullable=False), )
These are the mappers:
mapper(Ligand, ligand_table,
properties={
'ligand':relationship(LigandLigand,
primaryjoin=and_(ligand_table.c.id==ligand_ligand_table.c.ligand_id1,
ligand_table.c.id==ligand_ligand_table.c.ligand_id2),
backref=backref('ligandligand') ), })
mapper(LigandLigand, ligand_ligand_table,
properties={
'first_sphere': relationship(Ligand,
primaryjoin=and_(ligand_ligand_table.c.ligand_id2==ligand_table.c.id,
ligand_ligand_table.c.ligand_id1==ligand_table.c.id),
backref=backref('root')),
})
When I try to access to the ligand.ligand properties, this is empty
even if in the db there are relations. Where is the problem?
Thanks
--
-------------------------------------------------------------------
(o_
(o_ //\ Coltivate Linux che tanto Windows si pianta da solo.
(/)_ V_/_
+------------------------------------------------------------------+
| ENRICO MORELLI | email: [email protected] |
| * * * * | phone: +39 055 4574269 |
| University of Florence | fax : +39 055 4574253 |
| CERM - via Sacconi, 6 - 50019 Sesto Fiorentino (FI) - ITALY |
+------------------------------------------------------------------+
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.