psycopg
PostgreSQL database adapter for Python
Decision gist · record as of 2026-08-14
Yes. Psycopg 3 is production-stable, actively maintained, and the recommended PostgreSQL adapter for new Python projects. It has low installation friction, no known vulnerabilities, and a large user base. The LGPL-3.0-only license is permissive for most use cases (including proprietary applications that link to the library). Install it if you need to connect Python to PostgreSQL.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; a running PostgreSQL server and valid connection credentials are needed at runtime.
- Installation is straightforward with low friction; the package ships as a pure Python wheel.
- The project is actively maintained with recent commits and a substantial user base, indicating stable ongoing development.
License · maintenance · safety
LGPL-3.0-only (copyleft) — Psycopg is licensed under LGPL-3.0-only, a copyleft license. This means derivative works must be distributed under the same license, and source code must be made available; however, linking to the library from a proprietary application is permitted provided the library itself remains under LGPL.
last release 2026-05-01 (105 days) · last repo commit 2026-08-01 · 2,475 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 116,967,627 downloads/mo, #307 on PyPI
Alternatives
Verify before relying
pip install psycopg[binary,pool]
import psycopg
with psycopg.connect("postgresql://user:password@localhost/dbname") as conn:
with conn.cursor() as cur:
cur.execute("SELECT version()")
print(cur.fetchone())- Whether the optional extras (binary, pool) mentioned in the description are required for production use or recommended for performance
- Specific PostgreSQL server version compatibility beyond the Python version requirements
What it is and what it does
Psycopg 3 is the current-generation PostgreSQL adapter for Python, succeeding psycopg2. It provides a modern interface for connecting Python applications to PostgreSQL databases, handling connection management, query execution, result fetching, and type conversion between Python and PostgreSQL data types. The package is pure Python and depends only on typing-extensions and tzdata, making it lightweight and portable across macOS, Windows, and POSIX systems.
Developers use Psycopg 3 to build database-backed applications, run queries, manage transactions, and handle PostgreSQL-specific features from Python code. It supports Python 3.10 through 3.14 and both CPython and PyPy implementations. The project is actively maintained with recent updates and a large user base, making it a stable choice for new PostgreSQL-backed projects.
Use it for
- Building web applications that need to query and persist data in PostgreSQL databases
- Writing data processing scripts that extract, transform, and load data from PostgreSQL
- Creating backend services that manage user accounts, transactions, or other relational data
- Migrating from psycopg2 to a modern, actively maintained PostgreSQL adapter
- Developing applications that require transaction management and connection pooling with PostgreSQL
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Psycopg 3 is production-stable, actively maintained, and the recommended PostgreSQL adapter for new Python projects. It has low installation friction, no known vulnerabilities, and a large user base. The LGPL-3.0-only license is permissive for most use cases (including proprietary applications that link to the library). Install it if you need to connect Python to PostgreSQL.
Install
psycopg on PyPI
Before you install
Installation is straightforward with low friction; the package ships as a pure Python wheel. The project is actively maintained with recent commits and a substantial user base, indicating stable ongoing development.
Requires Python 3.10 or later; a running PostgreSQL server and valid connection credentials are needed at runtime.
License in practice
Psycopg is licensed under LGPL-3.0-only, a copyleft license. This means derivative works must be distributed under the same license, and source code must be made available; however, linking to the library from a proprietary application is permitted provided the library itself remains under LGPL.
Quickstart
pip install psycopg[binary,pool]
import psycopg
with psycopg.connect("postgresql://user:password@localhost/dbname") as conn:
with conn.cursor() as cur:
cur.execute("SELECT version()")
print(cur.fetchone())
Verify before relying
- Whether the optional extras (binary, pool) mentioned in the description are required for production use or recommended for performance
- Specific PostgreSQL server version compatibility beyond the Python version requirements
Package facts
| License | LGPL-3.0-only copyleft |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagestyping-extensionstzdata |
| Maintenance | Actively maintained 105 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 116,967,627 / month, #307 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: DatabaseTopic :: Database :: Front-EndsTopic :: Software DevelopmentTopic :: Software Development :: Libraries :: Python Modules |
Evidence: psycopg-3.3.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “postgresql python adapter”
- psycopgPsycopg 3 is a PostgreSQL database adapter for Python that enables…
- psycopg-cpsycopg-c is an optional C-compiled optimization package for Psycopg…
- psycopg-binaryProvides compiled C optimizations for the PostgreSQL database…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also psycopg-pool · PyGreSQL · postgres · psycopg-binary · psycopg-c · psycopg2 · psycopg2-binary · PyPgConfig · aws-psycopg2 · django-db-geventpool