Skip to main content

A Python package to dynamically load CSV files into PostgreSQL tables.

Project description

๐Ÿ“ฆ havinosh_data_loader: CSV to PostgreSQL Ingestion

Seamlessly load CSV files into PostgreSQL dynamically.

Python
PostgreSQL
License
Status


๐Ÿš€ Overview

havinosh_data_loader is a powerful Python package designed to automatically detect CSV structure, create tables, and insert data into PostgreSQL with minimal effort.
Simply drop your CSV files into a folder, and havinosh_data_loader will handle everything dynamically.


๐Ÿ“Œ Features

โœ… Automatic Table Creation โ€“ Reads CSV headers and maps them to PostgreSQL columns
โœ… Dynamic Schema Detection โ€“ Infers data types automatically
โœ… Batch Data Insertion โ€“ Efficiently loads large datasets
โœ… Error Handling โ€“ Logs errors and provides detailed debugging
โœ… Environment Configuration โ€“ Uses .env file for database credentials
โœ… Modular & Extensible โ€“ Well-structured for easy modifications


๐Ÿ“‚ Project Structure

havinosh_data_loader/
โ”‚โ”€โ”€ havinosh_data_loader/                   # Main package directory
โ”‚   โ”œโ”€โ”€ __init__.py           # Package initialization
โ”‚   โ”œโ”€โ”€ config.py             # Database configuration
โ”‚   โ”œโ”€โ”€ process_csv.py        # CSV processing logic (OOP-based)
โ”‚   โ”œโ”€โ”€ db_utils.py           # PostgreSQL connection utilities
โ”‚   โ”œโ”€โ”€ exception.py          # Custom exception handling
โ”‚   โ”œโ”€โ”€ logger.py             # Logging setup
โ”‚โ”€โ”€ scripts/                  # Command-line scripts
โ”‚   โ”œโ”€โ”€ ingest.py             # Main ingestion script (CLI)
โ”‚โ”€โ”€ tests/                    # Unit tests
โ”‚   โ”œโ”€โ”€ test_process_csv.py
โ”‚โ”€โ”€ csv_files/                # CSV storage (ignored in production)
โ”‚โ”€โ”€ setup.py                  # Package setup script
โ”‚โ”€โ”€ requirements.txt          # Dependencies
โ”‚โ”€โ”€ README.md                 # Documentation
โ”‚โ”€โ”€ .gitignore                # Ignore unnecessary files
โ”‚โ”€โ”€ LICENSE                   # License details

๐Ÿ›  Installation

1๏ธโƒฃ Install via pip

Once published to PyPI, you can install havinosh_data_loader using:

pip install havinosh_data_loader

2๏ธโƒฃ Install from Source

Clone the repository and install dependencies:

git clone https://github.com/IAMDSVSSANGRAL/havinosh_data_loader.git  
cd havinosh_data_loader  
pip install -r requirements.txt  

โš™ Usage

1๏ธโƒฃ Set Up Your Environment

๐Ÿ”น Using a .env File (Recommended)

Create a .env file in the root directory and add:

DB_NAME=your_database
DB_USER=your_username
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432

๐Ÿ’ก Note: This package requires .env for database credentials.


2๏ธโƒฃ Using the CLI

Basic Ingestion (Uses .env for DB credentials)

python scripts/ingest.py --folder csv_files

3๏ธโƒฃ Using the Python Package in Your Script

You can also use havinosh_data_loader programmatically within a Python script:

from havinosh_data_loader import Database, CSVProcessor, Config

# Load database configuration from .env
config = Config()
db = Database(config.get_config())

# Define the folder where CSV files are stored
csv_folder = "csv_files/"

# Initialize the processor
processor = CSVProcessor(db_instance=db, csv_folder=csv_folder)

# Start the ingestion process
processor.process_csv()

๐Ÿงช Testing

Run unit tests using:

pytest tests/

๐Ÿ”ฅ Limitations & Future Enhancements

  • ๐Ÿšง Does not support nested JSON in CSV fields
  • ๐Ÿš€ Planned: Add parallel processing for large datasets

๐Ÿ“œ License

This project is licensed under the MIT License โ€“ see the LICENSE file for details.


๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a branch (feature-xyz)
  3. Commit your changes
  4. Push and submit a Pull Request

๐Ÿ“ฌ Contact

๐Ÿ“ง Email: support@havinosh.com
๐ŸŒ GitHub: VISHAL SINGH SANGRAL


๐Ÿ”น What's New in This Version?

This version includes major improvements to enhance usability and clarity:
โœ… Refactored to OOP-based structure โ€“ CSVProcessor, Database classes added
โœ… Improved CLI Usage โ€“ Removed incorrect --db_name argument, making .env mandatory
โœ… Better Documentation โ€“ Clarified import structure for easier package use
โœ… Enhanced Logging & Exception Handling โ€“ Better debugging experience
โœ… More Detailed Testing Instructions โ€“ Now includes a dedicated testing section
โœ… Added Future Enhancements Section โ€“ Transparency on upcoming features


๐Ÿš€ Happy Data Ingestion! ๐ŸŽ‰

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

havinosh_data_loader-0.0.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

havinosh_data_loader-0.0.3-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file havinosh_data_loader-0.0.3.tar.gz.

File metadata

  • Download URL: havinosh_data_loader-0.0.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for havinosh_data_loader-0.0.3.tar.gz
Algorithm Hash digest
SHA256 37fbfdf22ffbf1812e63630ecfa1623c8558d99591a3c3d692ba2502530ff552
MD5 5907538206a2bbfc5a924eeb8ba86e33
BLAKE2b-256 6d1b720e88270b3d4eed297dba33d15fd5cf1ae5c6e358fe413cc61fc5cb0b1d

See more details on using hashes here.

File details

Details for the file havinosh_data_loader-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for havinosh_data_loader-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4c101217a8611e20a1331011261386d8ac1dc42f314a00a42226c81003d3e4
MD5 1e867c3981a1f79d1e13d0005eab5dfa
BLAKE2b-256 cfd5dae7ed4c21bbae5ac4c4154afa20710d086905736c92a01d4c27aa7b8633

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