Skip to main content

pydbc driver for PostgreSQL — wraps psycopg2 (pyformat paramstyle)

Project description

alt-python-pydbc-pg

pydbc driver for PostgreSQL via psycopg2.


Installation

uv add alt-python-pydbc-pg

Note: psycopg2-binary is installed automatically and works for development and CI. For production deployments, replace it with psycopg2 (compiled against the system libpq). See the psycopg2 installation docs for details.


URL format

pydbc:pg://user:password@host:port/dbname

The port defaults to 5432 if omitted.


Usage

import pydbc_pg  # registers PgDriver with DriverManager
from pydbc_core import DriverManager

conn = DriverManager.get_connection("pydbc:pg://alice:secret@localhost:5432/mydb")
stmt = conn.create_statement()
rs = stmt.execute_query("SELECT 1 AS n")
print(rs.rows)   # [(1,)]
conn.close()

Parameterised queries

# Positional parameters
stmt = conn.create_statement()
rs = stmt.execute_query("SELECT * FROM users WHERE id = ?", (42,))

# Named parameters
rs = stmt.execute_query("SELECT * FROM users WHERE id = :id", {"id": 42})

Prepared statements

ps = conn.prepare_statement("INSERT INTO users (name, email) VALUES (?, ?)")
ps.execute_update(("Alice", "alice@example.com"))
conn.commit()

Paramstyle note

psycopg2 uses pyformat (%s / %(name)s) placeholders internally. pydbc accepts both ? (positional) and :name (named) syntax and translates automatically — you never need to know which style the underlying driver uses.


Documentation


License

MIT

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

alt_python_pydbc_pg-1.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alt_python_pydbc_pg-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file alt_python_pydbc_pg-1.0.0.tar.gz.

File metadata

  • Download URL: alt_python_pydbc_pg-1.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for alt_python_pydbc_pg-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2170fda2829a5727d88d253fe022fae1cf81a273e9ee33d43a6d3729536cebd5
MD5 9e540ce389f5f8dd6c3a3a43307a4e41
BLAKE2b-256 11209d3ca9b16b3c2b22781e46963a160937f8b8c8697bf1dab6a56a5ee4c767

See more details on using hashes here.

File details

Details for the file alt_python_pydbc_pg-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: alt_python_pydbc_pg-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for alt_python_pydbc_pg-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fe3a9127413237158f3182dd60a1c92a58cb99c9998124841f756f7753a1a79
MD5 dd25cf43fd4c4727bcb2ebd21e2e29b6
BLAKE2b-256 f33dd977a053232209200064f2abef94daf5b73c48198cbe8da3bf77c6430be3

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