在此先感谢您的帮助。我必须将以下 SQL 语句转换为 SQL alchemy。我以前没有使用过 SQL Alchemy。
SQL:
SELECT User.id, User.nicknames
FROM users, breadcrumbs
WHERE user_id in my_friend_ids
AND user_id = bc.creator_id
AND bc.location_id = loc_id
my_friend_ids = select friend_id from friends
where user_id = requestor_id and status ='approved'
到目前为止我得到了什么:
my_friend_ids = select([Friend.user_id]).select_from(Friend).\
where(and_(Friend.friend_id == user_id,
Friend.status == 'approved'))