pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/fastapi/sqlmodel/blob/main/docs/tutorial/fastapi/delete.md

ub.githubassets.com/assets/global-0bd78641c0a1f3e0.css" /> sqlmodel/docs/tutorial/fastapi/delete.md at main · fastapi/sqlmodel · GitHub
Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 883 Bytes

File metadata and controls

29 lines (17 loc) · 883 Bytes

Delete Data with FastAPI

Let's now add a path operation to delete a hero.

This is quite straightforward. 😁

Delete Path Operation

Because we want to delete data, we use an HTTP DELETE operation.

We get a hero_id from the path parameter and verify if it exists, just as we did when reading a single hero or when updating it, possibly raising an error with a 404 response.

And if we actually find a hero, we just delete it with the session.

{* ./docs_src/tutorial/fastapi/delete/tutorial001_py310.py ln[89:97] hl[89:97] *}

After deleting it successfully, we just return a response of:

{
    "ok": true
}

Recap

That's it, feel free to try it out in the interactive docs UI to delete some heroes. 💥

Using FastAPI to read data and combining it with SQLModel makes it quite straightforward to delete data from the database.

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy