Registry / database / pgdb
library0.0.11pypypi✓ verified 85d ago

pgdb is a lightweight Python wrapper around `psycopg2-binary` designed to simplify basic interactions with PostgreSQL databases. It provides a simple API for connecting, executing queries, and fetching results. The library, currently at version 0.0.11, appears to be in maintenance mode with its last update over two years ago.

pip install pgdb
INSTALL
IMPORT
SIG · PGDB
P
pgdb
databasepythonv0.0.11
Install
2.7s avg
Import
51ms
Disk
27MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.11 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.051s · 27.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.7s · import 0.050s · 31MB
27MB installed
● package 27MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

connect
import pgdb
The `connect` function is directly accessible as `pgdb.connect` after importing the `pgdb` module.

This quickstart demonstrates how to establish a connection, create a table, insert data, and fetch results using `pgdb`. It utilizes environment variables for database credentials, falling back to common defaults for local testing. It also includes basic error handling and resource cleanup.

import pgdb import os DB_HOST = os.environ.get('PGDB_HOST', 'localhost') DB_NAME = os.environ.get('PGDB_DATABASE', 'test_db') DB_USER = os.environ.get('PGDB_USER', 'postgres') DB_PASS = os.environ.get('PGDB_PASSWORD', 'mysecretpassword') # REMEMBER to change in prod conn = None try: conn = pgdb.connect(host=DB_HOST, database=DB_NAME, user=DB_USER, password=DB_PASS) cursor = conn.cursor() # Cleanup for re-runs and create table cursor.execute("DROP TABLE IF EXISTS example_data;") cursor.execute("CREATE TABLE example_data (id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL);") conn.commit() # Insert data cursor.execute("INSERT INTO example_data (name) VALUES ('Alice'), ('Bob'), ('Charlie');") conn.commit() # Fetch and print data cursor.execute("SELECT id, name FROM example_data;") print("Fetched data:") for row in cursor.fetchall(): print(row) except pgdb.Error as e: print(f"Database error: {e}") if conn: conn.rollback() # Rollback on error finally: if conn: conn.close()
Debug
Known issues
gotcha`pgdb` specifically requires `psycopg2-binary`. If you have `psycopg2` installed, `pgdb` might attempt to use it, but its `setup.py` explicitly lists `psycopg2-binary`.
fix
Ensure `psycopg2-binary` is installed: `pip install psycopg2-binary`. If you have `psycopg2` and encounter issues, consider uninstalling it before installing `pgdb`.
affects: 0.0.1 and later
gotchaAs a simple wrapper, `pgdb` offers basic database interaction but lacks advanced features like ORM capabilities, sophisticated connection pooling, or asynchronous operations found in larger, more actively maintained libraries (e.g., SQLAlchemy, asyncpg).
fix
Evaluate your project's needs. For complex applications requiring advanced features, consider using `psycopg2` directly or a more comprehensive ORM/database client library.
affects: All versions
deprecatedThe `pgdb` library has not been updated since February 2022, indicating a lack of active development or maintenance. This could lead to compatibility issues with newer Python versions or PostgreSQL features.
fix
For new projects or long-term critical applications, consider using more actively maintained PostgreSQL libraries like `psycopg2` (or `psycopg` for Python 3.7+), `psycopg2-binary`, or ORMs like SQLAlchemy that have robust community support and regular updates.
affects: All versions (due to inactivity)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pgdb'
The `pgdb` library is not installed in your Python environment.
fix
Install the library using pip: `pip install pgdb`
psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "postgres"
Incorrect database connection parameters (host, port, database name, user, or password) or the PostgreSQL server is not running/accessible.
fix
Double-check the `host`, `database`, `user`, and `password` arguments passed to `pgdb.connect()`. Ensure your PostgreSQL server is running and accessible from your application's environment.
AttributeError: 'module' object has no attribute 'connect'
This error can occur if you attempt to access `connect` incorrectly, for example, after a `from pgdb import *` or if the module itself is shadowed.
fix
Always import `pgdb` as a module (`import pgdb`) and then call the function via the module namespace (`pgdb.connect(...)`). Ensure no other file or module named `pgdb.py` is in your Python path that might shadow the installed library.
Upgrade
Version history
0.0.11latest on PyPI · released Jul 29, 2021
Audit
Dependencies
psycopg2-binaryrequiredpgdb is a wrapper around psycopg2, which provides the underlying PostgreSQL driver.
Agent activity
4 hits · last 30 days
node
4
Resources
pgdb — pip install pgdb · libregistry