$npx skillfedfor your agent

psycopg2

psycopg2 - Python-PostgreSQL Database Adapter

Worth itPyPI Software DevelopmentReleased Apr 202659.2M downloads / moLGPL with exceptionsPlatform wheel

Decision gist · record as of 2026-08-14

platform wheels — psycopg2-2.9.12-cp310-cp310-win_amd64.whl · psycopg2-2.9.12-cp311-cp311-win_amd64.whl · psycopg2-2.9.12-cp312-cp312-win_amd64.whl
v2.9.12 · released 2026-04-20 · Python >=3.9

Yes, for production PostgreSQL applications. Psycopg2 is the de facto standard adapter, actively maintained, has no known vulnerabilities, and is proven across millions of deployments. Install friction is moderate (C compilation) but manageable via pre-built wheels. If starting a new project, evaluate Psycopg 3 first, but Psycopg2 remains a solid, low-risk choice for existing codebases or when stability is paramount.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires a C compiler and PostgreSQL development libraries to build from source; pre-built wheels are available for Windows and common Python versions.
  • Alternatively, install psycopg2-binary for a pre-compiled option.
  • Medium install friction due to C compilation requirements; the package is actively maintained with recent releases and no known vulnerabilities.

License · maintenance · safety

LGPL with exceptions (copyleft) — Licensed under LGPL with exceptions (copyleft). You may use and modify the package freely, but any derivative works must also be distributed under compatible terms. Proprietary applications can typically link to it, but review the specific exceptions and your use case.

last release 2026-04-20 (116 days) · last repo commit 2026-05-02 · 3,652 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 59,190,867 downloads/mo, #511 on PyPI

Verify before relying

pip install psycopg2

import psycopg2
conn = psycopg2.connect('dbname=test user=postgres')
cur = conn.cursor()
cur.execute('SELECT version()')
print(cur.fetchone())
  • Whether the package's C implementation and libpq wrapper remain performant for your workload's concurrency and throughput requirements.
  • Compatibility of your PostgreSQL server version with the libpq version bundled or linked during installation.
  • Performance characteristics for applications creating and destroying many cursors or performing large numbers of concurrent operations.
Same gist for agents: .md · .json

What it is and what it does

Psycopg2 is a mature PostgreSQL adapter that bridges Python and PostgreSQL databases. It implements the Python DB API 2.0 specification and is built primarily in C as a wrapper around libpq, the PostgreSQL client library. The package is designed for multi-threaded applications and supports thread-safe connection sharing, client-side and server-side cursors, asynchronous communication, and PostgreSQL-specific features like COPY operations. It handles many Python types out of the box and adapts them to matching PostgreSQL data types; the adaptation system is extensible for custom types.

The package is actively maintained and widely used in production, though the documentation notes that new feature development has shifted to Psycopg 3. Psycopg2 remains a stable, production-ready choice for applications already using it or for projects prioritizing compatibility and maturity over cutting-edge features. Installation requires a C compiler and development libraries on most platforms, though pre-built wheels simplify setup on Windows and other common environments.

Use it for

  • Building web applications that need reliable PostgreSQL database connections with concurrent query execution.
  • Multi-threaded data processing pipelines that create and destroy many cursors and perform bulk INSERT or UPDATE operations.
  • ETL workflows using COPY TO/COPY FROM for efficient bulk data loading and extraction from PostgreSQL.
  • Legacy or mature production systems already standardized on Psycopg2 where stability and proven behavior are priorities.
  • Applications requiring server-side cursors for memory-efficient handling of large result sets.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes, for production PostgreSQL applications.

Psycopg2 is the de facto standard adapter, actively maintained, has no known vulnerabilities, and is proven across millions of deployments. Install friction is moderate (C compilation) but manageable via pre-built wheels. If starting a new project, evaluate Psycopg 3 first, but Psycopg2 remains a solid, low-risk choice for existing codebases or when stability is paramount.

Install

psycopg2 on PyPI

Before you install

Medium install friction due to C compilation requirements; the package is actively maintained with recent releases and no known vulnerabilities. Pre-built wheels are available for Windows and Python versions 3.9–3.14, reducing friction on those platforms. A binary-only alternative (psycopg2-binary) is available for development but not recommended for production.

Requires a C compiler and PostgreSQL development libraries to build from source; pre-built wheels are available for Windows and common Python versions. Alternatively, install psycopg2-binary for a pre-compiled option.

License in practice

Licensed under LGPL with exceptions (copyleft). You may use and modify the package freely, but any derivative works must also be distributed under compatible terms. Proprietary applications can typically link to it, but review the specific exceptions and your use case.

Quickstart

pip install psycopg2

import psycopg2
conn = psycopg2.connect('dbname=test user=postgres')
cur = conn.cursor()
cur.execute('SELECT version()')
print(cur.fetchone())

Verify before relying

  • Whether the package's C implementation and libpq wrapper remain performant for your workload's concurrency and throughput requirements.
  • Compatibility of your PostgreSQL server version with the libpq version bundled or linked during installation.
  • Performance characteristics for applications creating and destroying many cursors or performing large numbers of concurrent operations.

Package facts

LicenseLGPL with exceptions copyleft
Python supportSupports the current Python release >=3.9
Install frictionMedium. Platform-specific wheel
Runtime dependenciesNone
MaintenanceActively maintained 116 days since the last release
Last repo commit
First released
Downloads59,190,867 / month, #511 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)Operating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3Programming 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 :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: SQLTopic :: DatabaseTopic :: Database :: Front-EndsTopic :: Software DevelopmentTopic :: Software Development :: Libraries :: Python Modules

Evidence: psycopg2-2.9.12-cp310-cp310-win_amd64.whl; psycopg2-2.9.12-cp311-cp311-win_amd64.whl; psycopg2-2.9.12-cp312-cp312-win_amd64.whl; psycopg2-2.9.12-cp313-cp313-win_amd64.whl; psycopg2-2.9.12-cp314-cp314-win_amd64.whl; psycopg2-2.9.12-cp39-cp39-win_amd64.whl

Tags

Capabilities
postgresql python adapterpostgres database connectionpython db api postgresqlpsycopg2 database driversql query execution pythonpostgresql cursor managementthread-safe postgres client
Topics
postgresqldatabase-driverthread-safe

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 cursor management”

  • psycopg2PostgreSQL database adapter for Python that implements the DB API 2.0…
  • pgspecialExecutes PostgreSQL meta-commands (backslash commands)…
  • aiopgaiopg provides asyncio-based access to PostgreSQL databases, wrapping…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

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.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

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.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

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.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

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.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

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.

permissive licensepure Python
323.3Mdownloads / mo

See also pg8000 · psycopg2-binary · PyGreSQL · aws-psycopg2 · postgres · psycopg · psycopg-binary · psycopg-c · psycopg2-pool · pgdb