Is it possible to fill a SQLalchemy foreign key in a model and have it load the related object
<p>In SQLAlchemy, I have a <strong><em>transactionlog</em></strong> model, that has a related <strong><em>member</em></strong>. This relation is defined by a <em>tlog_ppl_id</em> column in the transactionlog table, that references a <em>ppl_id</em> column in a <em>people</em> table ( the <em>people</em> table contains <em>members</em>).</p>

<p>Suppose I have a new Transactionlog object T.
If I load a member-object (lets call it M), and set T.member = M, I can access T.member and it returns my linked member.</p>

<p>What I'd like to do is have my new transactionlog SQLAlchemy object T, and fill the tlog_ppl_id property with a valid ppl_id.
After I do that, I'd like to access T.member, and have SQLAlchemy load the related people record from the database. It does not do so however, it returns <em>None</em>.</p>

<p>So I wonder if it is possible to have SQLAlchemy load the related objects with a specific instruction, if I only fill the objects foreign key columns?</p>

<p>code to test this:</p>

<pre><code>def test():
    from app.models.data import Transactionlog
    T = Transactionlog()
    T.tlog_ppl_id = '2433A992-B8C7-4780-91DE-67D12C517C55'
    print(T.member)
    return ""
</code></pre>

<p>code in the model:</p>

<pre><code>class Transactionlog(transactionlog):
    """
    Transactionlog model class.
    """

    member = relationship("People", backref=backref('transactions'))
</code></pre>

<p>I'm using SQLalchemy 1.0.14 on Python 3.5.1 under flask (not using flask-sqlalchemy)</p>