How To Install python3-psycopg on Debian 12

Learn how to install python3-psycopg on Debian 12 with this tutorial. python3-psycopg is PostgreSQL database adapter for Python 3

Introduction

In this tutorial we learn how to install python3-psycopg on Debian 12.

What is python3-psycopg

python3-psycopg is:

Psycopg 3 is a newly designed PostgreSQL database adapter for the Python programming language.

Psycopg 3 is a complete rewrite of Psycopg 2, maintaining the same fundamental libpq wrapper architecture and DB-API interface design, but exposing new features to better work with the newer versions of Python and PostgreSQL.

On the Python side, Psycopg 3 allows the use of asyncio-based concurrency and static typing. Many improvement to the Python interface make the library much simpler and more idiomatic to use,

On the PostgreSQL side, Psycopg 3 makes use of server-side parameters, prepared statements, binary parameters, and great support for COPY operations.

Psycopg 3 presents a familiar interface for everyone who has used Psycopg 2 or any other DB-API 2.0 database adapter, but allows one to use more modern PostgreSQL and Python features, such as:

  • Strict Strong Typing
  • asynchronous support
  • server-side parameters binding
  • binary communication
  • a great integration of the COPY support
  • direct access to the libpq functionalities

There are three methods to install python3-psycopg on Debian 12. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python3-psycopg Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python3-psycopg using apt-get by running the following command:

sudo apt-get -y install python3-psycopg

Install python3-psycopg Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python3-psycopg using apt by running the following command:

sudo apt -y install python3-psycopg

Install python3-psycopg Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python3-psycopg using aptitude by running the following command:

sudo aptitude -y install python3-psycopg

How To Uninstall python3-psycopg on Debian 12

To uninstall only the python3-psycopg package we can use the following command:

sudo apt-get remove python3-psycopg

Uninstall python3-psycopg And Its Dependencies

To uninstall python3-psycopg and its dependencies that are no longer needed by Debian 12, we can use the command below:

sudo apt-get -y autoremove python3-psycopg

Remove python3-psycopg Configurations and Data

To remove python3-psycopg configuration and data from Debian 12 we can use the following command:

sudo apt-get -y purge python3-psycopg

Remove python3-psycopg configuration, data, and all of its dependencies

We can use the following command to remove python3-psycopg configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python3-psycopg

Dependencies

python3-psycopg have the following dependencies:

References

Summary

In this tutorial we learn how to install python3-psycopg package on Debian 12 using different package management tools: apt, apt-get and aptitude.