Databases are often used as storage components in complex software solutions. Even if they could implement complex logic in triggers and functions, there is still a necessity for external applications to implement user interfaces. It's 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 don't. There are implementations of ORM for Python that work well with PostgreSQL.
The psycopg2, pg8000, and asyncpg low-level libraries were described in this chapter. They make it possible to connect to a database from a Python application...