--- id: types-psycopg2 version: "2.9.21.20260724" license: Apache-2.0 license_treatment: permissive maintenance: active --- # types-psycopg2 — Typing stubs for psycopg2 License: permissive · Maintenance: active · Downloads: 8.6M/mo ## What it is and what it does types-psycopg2 is a type stub package that adds static type information to psycopg2, the widely-used PostgreSQL adapter for Python. It allows type checkers like mypy and pyright to understand the types and signatures of psycopg2's API, catching type errors at development time rather than runtime. The stubs are maintained as part of the typeshed project and aim to provide accurate annotations for psycopg2 version 2.9.12. This package has no runtime dependencies and installs as a pure Python wheel. It is intended to be used alongside psycopg2 itself during development and type-checking workflows. The stubs have been tested with mypy 2.3.0 and pyright 1.1.411, and the package is actively maintained with recent updates. Use it for: - Enable mypy or pyright to type-check code that imports and uses psycopg2 for database connections. - Catch type errors in psycopg2 method calls and result handling before running tests. - Provide IDE autocomplete and inline type hints when working with psycopg2 in a type-aware editor. - Validate that database query results and cursor operations match expected types in a CI/CD pipeline. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides type hints for psycopg2, enabling static type checkers like mypy and pyright to validate code that uses the PostgreSQL adapter. Yes, if you use psycopg2 and run static type checking. The package is lightweight, has no dependencies, and is actively maintained. Install it alongside psycopg2 to enable type checking in your development workflow. Not necessary if you do not use a type checker or do not use psycopg2. ## Install pip install types-psycopg2 uv add types-psycopg2 poetry add types-psycopg2 ## Installing types-psycopg2 Before you install: Low install friction with no runtime dependencies. Actively maintained as part of typeshed; last commit 2026-08-14 and release 21 days ago. License in practice: Apache-2.0 is permissive; you may use, modify, and distribute this package freely in most contexts without restriction. Quickstart: pip install types-psycopg2 import psycopg2 conn = psycopg2.connect("dbname=test user=postgres") Requires Python >= 3.10. Type checking requires a compatible type checker (mypy 2.3.0 or pyright 1.1.411 or later). Verify before relying: - Coverage of psycopg2 API surface beyond 2.9.12 (e.g., newer versions or extensions). - Whether stubs are kept in sync with psycopg2 releases after 2.9.12. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 8.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags psycopg2 type hints, psycopg2 type stubs, postgresql adapter typing, mypy psycopg2 support, pyright psycopg2 annotations, type checking postgresql, psycopg2 static analysis, type-stubs, postgresql [View on SkillFed](https://skillfed.io/packages/types-psycopg2) · [View on PyPI](https://pypi.org/project/types-psycopg2/)