hi there,
I have a proble defining my relations.
I have thwo tables that are linked in a m:n relation using an association table
This works fine.
Now the problematic part:
each entry in the association table takes part in a m:n relationship to any
number of companies
This I can not do.
here are the involved tables:
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
class tblCompany(Base2):
__table__ = tables2['tblCompany']
# services
from sqlalchemy import Table
tblServiceTechnologyCompetence_has_tblCompany =
Table('tblServiceTechnologyCompetence_has_tblCompany', Base2.metadata,
autoload=True)
# technology tells us what technology like hybridkollektoren or
Niedertemperatursystem we are
# dealing with
class tblServiceTechnology(Base2):
__table__ = tables2["tblServiceTechnology"]
# category Kategorie wie Wärmeerzeugung, HLWDt
class tblServiceCategory(Base2):
__table__ = tables2["tblServiceCategory"]
# backref to the company
technologies = relationship(
tblServiceTechnology,
backref = backref('category')
)
# we have a m:n relationship between
# tblServiceTechnologyCompetence and tblServiceTechnology
# each such relationship has a m:n relationship to companies
class tblServiceTechnology_has_Competence(Base2):
__table__ = tables2["tblServiceTechnology_has_Competence"]
#backref to the company
companies = relationship(
'tblCompany',
secondary=tblServiceTechnologyCompetence_has_tblCompany,
backref="competences",
)
# competence tells us what competence like Systemanbieter, Herstellung, Planung
within a technology
# some entity is offering
class tblServiceTechnologyCompetence(Base2):
__table__ = tables2["tblServiceTechnologyCompetence"]
technologies = relationship(
"tblServiceTechnology",
secondary="tblServiceTechnology_has_Competence",
backref = 'competences'
)
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
now I get the error:
AttributeError: type object 'tblServiceTechnology_has_Competence' has no
attribute 'foreign_keys'
I tried also:
class tblServiceTechnologyCompetence(Base2):
__table__ = tables2["tblServiceTechnologyCompetence"]
technologies = relationship(
tblServiceTechnology,
secondary=tblServiceTechnology_has_Competence,
primaryjoin="tblServiceTechnology_has_Competence.idcompetence_comp_comp==tblServiceTechnologyCompetence.id",
secondaryjoin="tblServiceTechnology_has_Competence.idtechnology_comp_comp==tblServiceTechnology.id",
)
then the error I get is:
AttributeError: 'tblServiceTechnology_has_Competence' object has no
attribute 'c'
how should I define such a relationship.
thanks for your time
robert
--
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.