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.
You can install Nova PG directly from PyPI using pip:
pip install nova-pgOr, 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-pgThis 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.
Follow these steps to set up your local development environment:
-
Clone the repository:
git clone https://github.com/santarsierilorenzo/nova-pg.git
-
Copy the example dev container configuration file:
cp .devcontainer/devcontainer.json.example .devcontainer/devcontainer.json
-
Open VS Code and rebuild the container without cache:
Ctrl + Shift + P → Rebuild Container Without Cache and Reopen in Container -
Once the Docker container is running, you’ll have access to all required dependencies and tools pre-installed.
-
Copy
db_config.json.example, rename it todb_config.json, and fill it with your database credentials. -
Import the package:
import nova_pg- 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"
)- Build your connection string:
url_db = nova_pg.config.build_connection_string(
db_cred_dict=db_cred
)- Use functions in the
utilsmodule:
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
)