Connecting to a Relational Database
Our previous applications have only used Python collections to hold data records instead of persistent data stores. This setup causes data wiping whenever the Uvicorn server restarts because these collections only store the data in volatile memory, such as RAM. From this chapter onward, we will be applying data persistency to avoid data loss and provide a platform to manage our records, even when the server is in shutdown mode.
This chapter will focus on different Object Relational Mappers (ORMs) that can efficiently manage clients’ data using objects and a relational database. Object-relational mapping is a technique where SQL statements for Creating, Reading, Updating and Deleting (CRUD) are implemented and executed in an object-oriented programming approach. ORM requires all relationships or tables to be mapped to their corresponding entity or model classes to avoid tightly coupled connections to the database platform. And these model...