Summary
Applying ORM always has advantages and disadvantages for any application. It can bloat the application with so many configurations and layers of components, and it can even slow down the application if not managed well. But ORM, in general, can help optimize query development by simplifying the constructs by using its APIs and eliminating unimportant repetitive SQL scripts. Overall, it can reduce the time and cost of software development compared to using cursor
from psycopg2
.
In this chapter, four Python ORMs were used, studied, and experimented with to help FastAPI create its repository layer. First, there is SQLAlchemy, which provides a boilerplated approach to creating standard and asynchronous data persistency and query operations. Then, there is GINO, which uses the AsyncIO environment to implement asynchronous CRUD transactions with its handy syntax. Also, there is Pony, the most Pythonic among the ORMs presented because it uses hardcore Python code to build its repository...