I have been struggeling for a few days with this now and trying to see
if I maybe can get some help here. I'm using SQLAlchemy with Flask

This is what I have tried so far:

I got a user class defined like this:

association_table = db.Table('association',
    db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('friend_id', db.Integer, db.ForeignKey('friend.id'))
)

class Friend(db.Model):
    id = db.Column(db.Integer, primary_key=True)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True)
    password = db.Column(db.String(30))
    friends = db.relationship("Friend",
                    secondary=association_table)



Basically I want to have a relationship to other objects of class User
in the field User.friends

What am I doing wrong here?

Thanks,
Stefan

-- 
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.

Reply via email to