Database and object relational mappers
As we discussed in the previous chapters, Python provides us with a lot of object-oriented capabilities, and allows us to map our use cases in terms of classes and objects. Now, when we can map our problem set into a class and its objects, why shouldn't we also map our database tables as objects, where a particular class represents a table, and its objects represent the rows in the table. Going down this route helps us to maintain not only the consistency of how we write our code, but also how we model our problem.
The frameworks that provide the functionality through which we can map our databases to objects are known as ORMs and they help us to visualize our database as a set of classes and objects.
In the Python landscape, it is quite common to see ORMs. For example, a popular Python web framework, Django, provides its own ORM solution. Then, there is SQLAlchemy, which provides a fully-fledged ORM solution and database toolkit supporting a wide variety...