Skip to main content

PostgreSQL utilities

Project description

nova-pg

nova-pg is a Python package designed to simplify and streamline interactions with PostgreSQL databases.
It provides a set of helper functions that make it easier to connect, query, and manage data in a scalable and reusable way.

The main goal of this project is to accelerate development, enable scalability, and offer a portable package that can be easily integrated wherever database access is required.

Installation

You can install Nova PG directly from PyPI using pip:

pip install nova-pg

Or, if you want to test the latest version from TestPyPI, use:

pip install -i https://test.pypi.org/simple --extra-index-url https://pypi.org/simple nova-pg

Repository Structure

This repository includes:

  • Example configuration files for environment setup.
  • A dedicated test folder to validate the functionality of the helper functions.
  • A Docker-based development environment for consistent and isolated builds.

Development Setup

Follow these steps to set up your local development environment:

  1. Clone the repository:

    git clone https://github.com/santarsierilorenzo/nova-pg.git
    
  2. Copy the example dev container configuration file:

    cp .devcontainer/devcontainer.json.example .devcontainer/devcontainer.json
    
  3. Open VS Code and rebuild the container without cache:

    Ctrl + Shift + P  Rebuild Container Without Cache and Reopen in Container
    
  4. Once the Docker container is running, you’ll have access to all required dependencies and tools pre-installed.

Get Started

  1. Copy db_config.json.example, rename it to db_config.json, and fill it with your database credentials.

  2. Import the package:

import nova_pg
  1. Load your database credentials from db_config.json:
db_cred = nova_pg.config.load_db_config(
    config_file_path="path_to_your_json",
    env_name="dev"
)
  1. Build your connection string:
url_db = nova_pg.config.build_connection_string(
    db_cred_dict=db_cred
)
  1. Use functions in the utils module:
QUERY = """
SELECT *
FROM prices.nq_1_min
"""

with nova_pg.utils.get_cursor(url_db) as cur:
    cols, data = nova_pg.utils.fetch_in_chunks(
        cur=cur,
        query=QUERY,
        table_name="nq_1_min",
        batch_size=10000            
    )

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

nova_pg-0.1.9.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

nova_pg-0.1.9-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file nova_pg-0.1.9.tar.gz.

File metadata

  • Download URL: nova_pg-0.1.9.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for nova_pg-0.1.9.tar.gz
Algorithm Hash digest
SHA256 d651cfc98a5594629ad68d5a06e6d26c84c6a026526c1f3603e24a70643bcd5f
MD5 2f32c0ee6b522f760282aa608de9fc9f
BLAKE2b-256 7782c14e92a5e3007a31c17922c32cc0dfdec2084ebe570f47613a81f95d913b

See more details on using hashes here.

File details

Details for the file nova_pg-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: nova_pg-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for nova_pg-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 bc8fd3310427ef23ea1ce2cfbe02418a2dd1dddbc900ade97d2cbe5fd8b8da75
MD5 e9b4bc9c6d06b6637b8844df6ba15024
BLAKE2b-256 da9d940861800c442183c4a9c8611a09e292f4256f9d39f0f478ff7fa886b289

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