Python SQLmodel get items that pattern matches another table's item title
I have this API which should get all items from Item table that pattern matches in WantedItem table that Item.item_id doesnt exist in Table_3.item_id. @app.get("/wanted_items/{user_id}") def all_wanted_items(*, session: Session = Depends(get_session), user_id: UUID): get_all_items = session.exec( select(Item, WantedItem, Table_3) .where(WantedItem.user_id == user_id) .where(Item.item_id != Table_3.item_id) .where(col(Item.title).ilike(f"%{WantedItem.title}%")) ).all() if not get_all_items : raise HTTPException( status_code=404, detail="Some content", ) return [ { "item": item.model_dump(), "wa
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.