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 pgdbVerified import paths — ran on the pinned version, not inferred.
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.
Ensure `psycopg2-binary` is installed: `pip install psycopg2-binary`. If you have `psycopg2` and encounter issues, consider uninstalling it before installing `pgdb`.
Evaluate your project's needs. For complex applications requiring advanced features, consider using `psycopg2` directly or a more comprehensive ORM/database client library.
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.
Install the library using pip: `pip install pgdb`
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.
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.