Summary

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: psycopg2pg8000 and asyncpg. They make it possible to connect to a database from a Python application and execute SQL commands to retrieve or modify data.

Another library, SQLAlchemy, was described in the last section of the chapter. SQLAlchemy provides object relational mapping functionality that eases the implementation of business logic by mapping business entities to database tables. This makes it possible for a developer to concentrate on the application logic instead of low-level database interaction. Although developers must know what is happening in the systems they work with and be aware of how databases work, using ORM frameworks removes the necessity of writing SQL code.

From the last chapter of the book you will know how to use multiple PostgreSQL servers together to achieve greater performance or high availability, or both. This will make the software solution scalable and able to grow with the growth of the business using it. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset