Building the repository using Peewee
Among the different ORMs, Peewee is the simplest and smallest in terms of ORM features and APIs. The framework is easy to understand and use; it is not comprehensive, but it has intuitive ORM syntax. Its strength is in building and executing query transactions.
Peewee is not designed for asynchronous platforms, but it can work with them by using some async-related libraries that it supports. We need to install at least Python 3.7 for Peewee to work with FastAPI, an asynchronous framework. To install Peewee, we need to execute the following command:
pip install peewee
Installing the database driver
The ORM needs psycopg2
as the PostgreSQL database driver. We can install it using pip
:
pip install psycopg2
Creating the database connection
For Peewee to work with FastAPI, we must build a multi-threading mechanism where Peewee can cater to more than one request transaction on the same thread, and per request can do more executions...