Answer the question
In order to leave comments, you need to log in
How to loop through a structure obtained from Flask-SQLAlchemy?
Here is the code for querying MySQL:
U = User
I = UserItem
items = db.session.query(U, I).join(I).filter(U.id == user_id).all()
[
(<User(id=21, nickname=Olesya, [email protected], date=2011-11-09 11:02:51)>,
<UserItem(id=79, user_id=21, name_item=en, razg=1, revers=0, share=None)>),
(<User(id=21, nickname=Olesya, [email protected], date=2011-11-09 11:02:51)>,
<UserItem(id=81, user_id=21, name_item=en, razg=1, revers=2, share=None)>)
и т.д.
]
Answer the question
In order to leave comments, you need to log in
for i in items:
print i.UserItem.id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question