πŸ’­ Filter Data - WHERE - SQLModel ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ !https://sqlmodel.tiangolo.com/tutorial/where/#filter-rows-using-where-with-sqlmodel Date: July 28, 2023 Image: Filter Data - WHERE - SQLModel β€” SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness. Filter Data - WHERE - SQLModel SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness. sqlmodel.tiangolo.com When fetching pydantic models from the database with sqlmodel, and you cannot select your item by id, you probably need to use a where clause. This is the sqlmodel way of doing it. β”‚ Here is a snippet of how I am using sqlmodel select and where to find a post by link in my thoughts database. [code] @post_router.get("/link/") async def get_post_by_link( *, session: Session = Depends(get_session), link: str, ) -> PostRead: "get one post by link" link = urllib.parse.unquote(link) print(f'link: {link}') post = session.exec(select(Post).where(Post.link==link)).first() if not post: raise HTTPException(status_code=404, detail=f"Post not found for link: {link}") return post NOTE β”‚ This post is a thought </thoughts/>. It’s a short note that I make about someone else’s content online #thoughts </tags/thoughts/>