K
K
kamiram2012-11-01 11:36:18
Python
kamiram, 2012-11-01 11:36:18

Sqlalchemy get relation for foreignkey

How to get data for a column with a foreignkey on where it looks (better just a relation that is defined)
And just do how to get all defined relations?

for example we have:

class Producer(Base):
    __tablename__ = 'b_cat_producers'
    id = Column(Integer, primary_key=True, info={"title": "#", "readonly": True, "size": 5})
    name = Column(String(255), info={"title": u"Название", "size": 25})
    madein_id = Column(Integer, ForeignKey(Country.id))
    madein = relationship(Country,  primaryjoin="Country.id==Producer.madein_id")


How can I get a list from Producer which will contain madein? and how to find out Country from madein_id?
somewhere like this :)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question