Need help with psycopg3?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

516 Stars 36 Forks GNU Lesser General Public License v3.0 1.7K Commits 20 Opened issues


New generation PostgreSQL database adapter for the Python programming language

Services available


Need anything else?

Contributors list

Psycopg 3 -- PostgreSQL database adapter for Python

Psycopg 3 is a modern implementation of a PostgreSQL adapter for Python.


Quick version::

pip install --upgrade pip               # upgrade pip to at least 20.3
pip install psycopg[binary,pool]        # install binary dependencies

For further information about installation please check

the documentation

.. __:


In order to work on the Psycopg source code you need to have the

PostgreSQL client library installed in the system. For instance, on Debian systems, you can obtain it by running::
sudo apt install libpq5

After which you can clone this repository::

git clone
cd psycopg

Please note that the repository contains the source code of several Python packages: that's why you don't see a
here. The packages may have different requirements:
  • The

    directory contains the pure python implementation of
    . The package has only a runtime dependency on the
    , the PostgreSQL client library, which should be installed in your system.
  • The

    directory contains an optimization module written in C/Cython. In order to build it you will need a few development tools: please look at
    Local installation
    __ in the docs for the details.

.. __:

  • The
    directory contains the
    connection pools
    __ implementations. This is kept as a separate package to allow a different release cycle.

.. __:

You can create a local virtualenv and install there the packages

development mode
__, together with their development and testing requirements::
python -m venv .venv
source .venv/bin/activate
pip install -e ./psycopg[dev,test]      # for the base Python package
pip install -e ./psycopg_c              # for the C extension module
pip install -e ./psycopg_pool           # for the connection pool

.. _:

Now hack away! You can use tox to validate the code::

pip install tox
tox -p4

and to run the tests::

psql -c 'create database psycopg_test'
export PSYCOPG_TEST_DSN="dbname=psycopg_test"
tox -c psycopg -s
tox -c psycopg_c -s

Please look at the commands definitions in the

files if you want to run some of them interactively: the dependency should be already in your virtualenv. Feel free to adapt these recipes if you follow a different development pattern.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.