Databases are often used as a storage component of a complex software solution. Even if they could implement complex logic in triggers and functions, there is still a need for external applications to implement user interface. It is quite common to separate storage logic from business logic. In this case, the business logic is also performed in external applications.
In this chapter, you learned how to connect to a PostgreSQL database from applications written in Python. There are several libraries for Python that provide different programming interfaces for developers. Some of them implement the standard Python DB API and some do not. There are implementations of ORM (Object Relational Mapping) for Python that work well with PostgreSQL.
The following low level libraries were described in this chapter: psycopg2, pg8000 and asyncpg. They make it possible...