Skip to main content

A Python wrapper for PostgreSQL interaction using a C extension

Project description

Project Logo

Simple Python Wrapper for postgres connection.

license last-commit repo-top-language repo-language-count


Table of Contents


Overview

dxpq is a simple and intuitive Python library designed to facilitate connection and interaction with PostgreSQL databases. It was created with the goal of providing an efficient way to perform common PostgreSQL operations, such as executing SQL queries, inserting and updating data, and managing transactions.

This library is lightweight and easy to use, allowing developers to quickly connect to the database without the complexity of setting up additional packages. With support for basic SQL commands and transactions, dxpq offers a clear and straightforward interface for working with PostgreSQL.

Ideal for those seeking a minimalist solution focused only on essential database operations, dxpq is perfect for projects that don't require large frameworks or heavy libraries but still need robust communication with PostgreSQL.


Features

  • Database Connection: Easily establish a connection to a PostgreSQL database using a connection string.

  • Cursor Management: Create and manage cursors for executing SQL queries. Fetch all results or a single row, with support for different result formats (e.g., dictionary-style results).

  • SQL Execution: Execute SQL queries and commands with parameters for secure and dynamic query building.

  • Context Manager Support: The library supports context manager functionality, allowing the use of connections and cursors in with blocks for automatic resource management.

  • Cursor Types: Supports different cursor types, such as dictionary-style results, for easier access to columns by name.

  • Clean Resource Management: Automatically close database connections and cursors when done, either through context management or explicit cleanup with close() and __del__ methods.


Project Structure

└── dxpq/
    ├── README.md
    ├── dxpq
       ├── __init__.py
       ├── connection.py
       └── cursor.py
    ├── pyproject.toml
    ├── requirements-dev.txt
    └── requirements.txt

Getting Started

Prerequisites

This project requires the following dependencies:

  • Programming Language: Python
  • Package Manager: Pip

Installation

Build dxpq from the source and intsall dependencies:

  1. Clone the repository:

     git clone https://github.com/pedrohsbarbosa99/dxpq
    
  2. Navigate to the project directory:

     cd dxpq
    
  3. Install the dependencies: Using https://pypi.org/project/pip:

     pip install -r requirements.txt, requirements-dev.txt
    

Usage

Run the project with:

Using pip:

pip install dxpq
import dxpq

connection = dxpq.Connection("postgresql://postgres:postgres@localhost:5432/postgres")
with connection.cursor() as cursor:
    cursor.execute("select 1")
    cursor.fetchall()

Testing

Under development


Roadmap

  • Transaction support: Implement support to SQL commands

Contributing

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/pedrohsbarbosa99/dxpq
    
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
    
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
    
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
    
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


License

Dxpq is protected under the MIT License. For more details, refer to the LICENSE file.



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

dxpq-0.0.5.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file dxpq-0.0.5.tar.gz.

File metadata

  • Download URL: dxpq-0.0.5.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for dxpq-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9116ef317148d2489ba82e7ed97fe4c035e1d4ceb8d2838f1b4b3f6f46038a27
MD5 aa63163f3767c012229af8211733b66b
BLAKE2b-256 93fbbe9aca11ceafa6f6e390e053a36e15c8a995c443dc9c3966f9aa33e62b67

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