CLI tool
psycopg/psycopg avatar
psycopg/psycopg

Psycopg 3 is split into three packages, and the binary extra is what skips the C compiler

New generation PostgreSQL database adapter for the Python programming language

2,540 stars313 forksPythonLGPL-3.0

At a glance

What is it?
A PostgreSQL adapter for Python whose repository holds a pure Python core, a C and Cython speedup module and a separate connection pool package, each with its own requirements.
Who is it for?
Use Psycopg 3 if you want a direct PostgreSQL adapter for Python and are happy to write SQL yourself, installed with the binary and pool extras for a first run. Hold off if you need an ORM layer or a driver for another database, since the README presents only a PostgreSQL adapter.
Can I use it commercially?
Yes, with conditions. LGPL-3.0 is a weak copyleft licence: you can use it inside commercial and closed-source software, but if you distribute changes to its own files, you must publish those changes under the same licence.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • psycopg/psycopg2,540 ★ · +33
Star history
Repository2026-10-082026-11-25
psycopg/psycopg2.5k2.5k

33 Stars in the last 48 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

One pip line installs the driver, a bundled client library and the pool

The README's quick version is a single command:

code
pip install "psycopg[binary,pool]"

Two extras ride on the package name. The pool extra pulls in the connection pool, which lives in a separate package for reasons covered below. The binary extra is named in the command without explanation, and the README sends readers to the installation page of the documentation for the full story. What the README does say is that the pure Python package has a single runtime dependency, the libpq PostgreSQL client library, which should be installed on the system. A reader who installs the plain package on a machine without libpq should expect a failure to load it. The documentation link is the place to learn what the binary option replaces, so open it before choosing between binary and a local build.

psycopg, psycopg_c and psycopg_pool are three packages in one repository

The repository root holds psycopg, psycopg_c and psycopg_pool, alongside docs, tests and tools directories. The psycopg directory is the pure Python implementation. psycopg_c is an optimization module written in C and Cython, and building it needs development tools described under Local installation in the documentation. psycopg_pool holds the connection pool implementations and is kept as its own package to allow a different release cycle. That split has a practical effect on versions: the pool can ship a fix without a new driver release, and the driver can change without touching the pool. The README warns that the packages may have different requirements, so a contributor working only on psycopg does not need a compiler, while one touching psycopg_c does. The license is LGPL-3.0, and the repository has no GitHub releases, so versions are found on the package index.

Contributing starts with libpq: apt install libpq5, brew install libpq, or the EnterpriseDB installers

To work on the source you need libpq installed on the machine. On Debian systems the README gives:

code
sudo apt install libpq5

On macOS:

code
brew install libpq

On Windows, use EnterpriseDB's installers, which include libpq in the Command Line Tools. Then clone and enter the repository:

code
git clone https://github.com/psycopg/psycopg.git
cd psycopg

The same libpq requirement appears in the Cross-compiling section. Cross-platform zipapps built with shiv that include Psycopg as a dependency must also have libpq installed on the target. So an application bundle does not make the client library optional, and anyone shipping a zipapp to another machine has to plan for it.

Editable installs need editable_mode=strict to dodge a setuptools bug

The development setup creates a virtualenv and installs three things:

code
python -m venv .venv
source .venv/bin/activate

# Install the base Psycopg package in editable mode
pip install --config-settings editable_mode=strict -e "./psycopg[dev,test]"

# Install the connection pool package in editable mode
pip install --config-settings editable_mode=strict -e ./psycopg_pool

# Install the C speedup extension
pip install ./psycopg_c

The C extension is installed normally, without -e, while the other two are editable. The README says editable_mode=strict will probably be required to work around the problem of the editable mode broken, linking to an issue in the setuptools tracker. If imports resolve to the wrong files after an editable install, that flag is the first thing to check. The build system in pyproject.toml requires setuptools 49.2.0 or later and wheel 0.38.1 or later.

The test suite needs a live PostgreSQL database named psycopg_test

Tests run against a real server. The README creates the database with psql, points the suite at it through an environment variable, and runs pytest:

code
psql -c 'create database psycopg_test'
export PSYCOPG_TEST_DSN="dbname=psycopg_test"
pytest

If some tests fail on a local host, the README suggests excluding the proxy, subprocess or timing groups, for example with pytest -m 'not proxy and not timing'. Those names tell you which tests depend on the host environment. The pytest configuration in pyproject.toml runs with -ra, uses tests as its test path, and sets filterwarnings to error, so any warning raised during a test fails it. A contributor on a new Python release should expect warnings to surface as failures. Coverage is measured over psycopg and psycopg_pool, not psycopg_c, so the C module's behavior is checked only through the tests that exercise it from Python. The database is created with plain psql, which means the user running the tests needs permission to create databases on the server you point it at.

Strict mypy, pre-commit hooks and conventional commits gate every contribution

The README asks contributors to run pre-commit install, so lint errors show up before a merge request is submitted. Commit messages must follow the conventional commits specification. pyproject.toml sets mypy to strict mode across psycopg, psycopg_pool, psycopg_c and the tests, with warn_unused_ignores on and error codes shown. Tests and scrap modules get looser rules (check_untyped_defs is on, disallow_untyped_defs is off), and a few third-party modules such as dns, numpy and shapely have ignore_missing_imports. The file also turns off mypy's SQLite cache, with a comment that it exposes concurrency issues under parallel runs by pre-commit. The top level carries .flake8, .yamllint.yaml and .pre-commit-config.yaml, and codespell and isort are configured with the black profile. Expect a patch to be checked on style, types and spelling before a reviewer reads it.

Where the README stops: async usage, ORM features and comparisons with other drivers

The README is an install and contribution page. It describes Psycopg 3 only as a modern implementation of a PostgreSQL adapter for Python, so it makes no claim to be an ORM and documents no query API. It does not show a connection example, async usage, pooling parameters or type adaptation. Those live under the documentation at psycopg.org, including a page on the pool. The test files named test_tstring.py and test_tstring_async.py in the mypy exclusions hint at async test coverage and template string work, but the README says nothing about either, so treat them as pointers to the source and not as documented features. Comparisons with psycopg2, asyncpg or SQLAlchemy are absent here. The last push was on 12 October 2026, and the repository is not archived.

Editorial conclusion

Use Psycopg 3 if you want a direct PostgreSQL adapter for Python and are happy to write SQL yourself, installed with the binary and pool extras for a first run. Hold off if you need an ORM layer or a driver for another database, since the README presents only a PostgreSQL adapter. Before deploying, check how libpq is provided on your target system, because the pure Python package depends on it at runtime.

Frequently asked questions

What is psycopg used for?

It is a modern PostgreSQL database adapter for Python, called Psycopg 3 in the README. It connects Python programs to PostgreSQL servers.

How do I install psycopg?

The README's quick version is pip install "psycopg[binary,pool]". The pure Python package needs the libpq client library installed on the system, and the documentation has the full installation page.

Is psycopg an ORM?

The README describes it as a PostgreSQL database adapter for Python and does not call it an ORM. Its documentation is where query and type handling are covered.

Official sources

  1. Issues
  2. License: LGPL-3.0
  3. Project website
  4. psycopg/psycopg on GitHub
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/psycopg-psycopg.svg)](https://hysenlabs.com/projects/psycopg-psycopg)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/psycopg-psycopg.svg)](https://hysenlabs.com/projects/psycopg-psycopg)

Was this useful?