Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the problem is that you use <code>db.relationship()</code> in both <code>Person</code> and <code>WorkGroup</code> classes. Set it in one of them and use <code>backref</code> keyword argument to define the relationship on the other side.</p> <p>The other problem is that you've placed your foreign key in the wrong class. Since you want to have <a href="http://docs.sqlalchemy.org/en/rel_0_8/orm/relationships.html#many-to-one" rel="nofollow">many-to-one</a> relationship between <code>Person</code> and <code>WorkGroup</code> (many persons in one workgroup), you need to define <code>workgroup_id</code> FK in <code>Person</code> class and remove <code>members_id</code> (and <code>members</code>) from <code>WorkGroup</code>.</p> <p>After these changes I've got <code>CircularDependencyError</code> exception, most likely due to <code>prevPairings_id</code> FK <a href="http://docs.sqlalchemy.org/en/rel_0_8/orm/relationships.html#post-update" rel="nofollow">pointing to the same row</a>. Adding <code>post_update=True</code> to <code>prevPairings</code> relationship fixed that.</p> <p>So here are all the fixes you need to do for your code to work:</p> <pre><code>class Person(db.Model): # ... workgroup_id = db.Column(db.Integer, db.ForeignKey('workgroup.id')) # No need to set uselist=False, it will be determined automatically by # type of relationship (many-to-one in this case). workGroup = db.relationship("WorkGroup", backref='members') # ... prevPairings = db.relationship('Person', post_update=True) # ... class WorkGroup(db.Model): # ... # Removed members_id and members. # ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload