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.
๐ 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:
- Fork the repository
- Create a branch (
feature-xyz) - Commit your changes
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37fbfdf22ffbf1812e63630ecfa1623c8558d99591a3c3d692ba2502530ff552
|
|
| MD5 |
5907538206a2bbfc5a924eeb8ba86e33
|
|
| BLAKE2b-256 |
6d1b720e88270b3d4eed297dba33d15fd5cf1ae5c6e358fe413cc61fc5cb0b1d
|
File details
Details for the file havinosh_data_loader-0.0.3-py3-none-any.whl.
File metadata
- Download URL: havinosh_data_loader-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d4c101217a8611e20a1331011261386d8ac1dc42f314a00a42226c81003d3e4
|
|
| MD5 |
1e867c3981a1f79d1e13d0005eab5dfa
|
|
| BLAKE2b-256 |
cfd5dae7ed4c21bbae5ac4c4154afa20710d086905736c92a01d4c27aa7b8633
|