Creating CRUD operations
This recipe will show you how to make the basic CRUD operations work with the CSV file that acts as a database.
We will begin by making a draft for a simple list of tasks in CSV format and we will put the operations in a separate Python module. By the end of the recipe, you will have all the operations ready to be used by the API’s endpoints.
How to do it…
Let’s start by creating a project root directory called task_manager_app
to host our code base for our application:
- Move into the root project folder and create a
tasks.csv
file, which we will use as a database and put a few tasks inside:id,title,description,status 1,Task One,Description One,Incomplete 2,Task Two,Description Two,Ongoing
- Then, create a file called
models.py
, containing the Pydantic models that we will use internally for the code. It will look like the following:from pydantic import BaseModel class Task(BaseModel): title: str...