Skip to content

Basic CRUD operations performed on a Postgres database created with FastAPI and tested using PostMan

Notifications You must be signed in to change notification settings

neiljdo/fastapi-crud-operations

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

fastapi-crud-operations

Basic CRUD operations performed on a Postgres database created with FastAPI, validated with Pydantic, ORM operations using SQLAlchemy and tested using Postman

Requirements

pip install fastapi[all] psycopg2==2.9.3 pydantic==1.9.0 SQLAlchemy==1.4.31

Software Required

PostGreSQL  Visual Studio Code  Postman

Command to run server

uvicorn main:app --reload

About CRUD

Create POST /posts @app.post("/posts)

Read GET  /posts/:id @app.get("/posts/{id})
     GET  /posts @app.get("/posts)

Update PUT/PATCH  /posts/:id @app.put("/posts/{id})

Delete DELETE  /posts/:id @app.delete("/posts/{id})

PostMan test routes

GET all posts: http://127.0.0.1:8000/posts
GET single post: http://127.0.0.1:8000/posts/<post_id>
POST create post: http://127.0.0.1:8000/posts
  # body
  {
    "title": "Welcome to Wano",
    "content": "Hey Monkey D Luffy",
    "published": true
  }
DELETE post: http://127.0.0.1:8000/posts/<post_id>
UPDATE post: http://127.0.0.1:8000/posts/<post_id>
  # body
  {
    "title": "Welcome to Onigashima",
    "content": "I will be the pirate king"
  }

About

Basic CRUD operations performed on a Postgres database created with FastAPI and tested using PostMan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%