Using Pony ORM for the repository layer
Pony ORM relies on Python syntax for building the model classes and repository transactions. This ORM only uses Python data types such as int
, str
, and float
, as well as class types to implement model definitions. It applies Python lambda
expressions to establish CRUD transactions, especially when mapping table relationships. Also, Pony heavily supports JSON conversion of record objects when reading records. On the other hand, Pony can cache the query objects, which provides faster performance than the others. The code for Pony ORM can be found in the ch05a
project.
To use Pony, we need to install it using pip
. This is because it is a third-party platform:
pip install pony
Installing the database driver
Since Pony is an ORM designed to build synchronous transactions, we will need the psycopg2
PostgreSQL driver. We can install it using the pip
command:
pip install psycopg2
Creating the database’s connectivity
The approach...