psycopg3

Psycopg 3 is a newly designed PostgreSQL database adapter for the Python programming language. Psycopg 3 presents a familiar interface for everyone who has used Psycopg 2 or any other DB-API 2.0 database adapter, but allows to use more modern PostgreSQL and Python features.

Install

pip install --upgrade 'psycopg[binary]'

Synopsis

import psycopg

with psycopg.connect("postgres://crate@localhost:5432/") as conn:
    with conn.cursor() as cursor:
        cursor.execute("SELECT * FROM sys.summits")
        for record in cursor:
            print(record)

Features

  • Asynchronous support

  • COPY support from Python objects

  • A redesigned connection pool

  • Support for static typing

  • Server-side parameters binding

  • Prepared statements

  • Statements pipeline

  • Binary communication

  • Direct access to the libpq functionalities

See also

  Documentation

The full documentation for psycopg3.

psycopg3 documentation