Azure Database for PostgreSQL and Python can be used together for data analysis – PostgreSQL as database engine and Python as statistical tool. When dealing with large datasets that potentially exceed the memory of your machine it is recommended to push the data into database engine, where you can query the data in smaller digestible chunks.

In this article we will learn how to use Python to perform the following tasks:

Create Azure Database for PostgreSQL using azure python sdk

Connect to Azure Database for PostgreSQL using psycopg2

Create databases and tables

Load data from pandas dataframe into a table

Query data from table

Visualize data from table using plotnine

Delete Azure Database for PostgreSQL server using azure python sdk