can i import data from a joined table as a current readable column in sqlalchemy?

You can use the hybrid_property decorator to define an attribute on your class:

class Contact(db.Model):
...
    @hybrid_property
    def organization_id(self):
        return self.company.organization_id if self.company else None

Using contact.organization_id will load the company using the foreign key relationship.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top