Skip to main content

Query PostgreSQL databases using Python and the PQv3 protocol.

Project description

About

py-postgresql is a Python 3 package providing modules for working with PostgreSQL. Primarily, a high-level driver for querying databases.

While py-postgresql is still usable for many purposes, asyncpg and PostgREST are likely more suitable for most applications:

py-postgresql, currently, does not have direct support for high-level async interfaces provided by recent versions of Python. Future versions may change this.

Advisory

In v2.0, many, potentially breaking, changes are planned. If you have automated installations using PyPI, make sure that they specify a major version.

Installation

From PyPI using pip:

python3 -m pip install py-postgresql

From GitHub using a full clone:

git clone https://github.com/python-postgres/fe.git
cd fe
python3 ./setup.py install

Basic Usage

import postgresql
db = postgresql.open('pq://user:password@host:port/database')

get_table = db.prepare("SELECT * from information_schema.tables WHERE table_name = $1")
print(get_table("tables"))

# Streaming, in a transaction.
with db.xact():
	for x in get_table.rows("tables"):
		print(x)

REPL with connection bound to db builtin:

python3 -m postgresql.bin.pg_python -I 'pq://postgres@localhost:5423/postgres'

Documentation

Related

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_postgresql-1.3.1.tar.gz (275.5 kB view details)

Uploaded Source

File details

Details for the file py_postgresql-1.3.1.tar.gz.

File metadata

  • Download URL: py_postgresql-1.3.1.tar.gz
  • Upload date:
  • Size: 275.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for py_postgresql-1.3.1.tar.gz
Algorithm Hash digest
SHA256 ba476437aa4787f0a5e23a92086d4d47301cca398d8943ef29ba4272c56d7b8c
MD5 40d26d18a2e63f08cc9686a999d64ff4
BLAKE2b-256 269eb27d49f30b23a0e5f147509ad463ecf6b87bd653d764ef7ef3da8f938188

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page