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 Python package designed to automatically detect CSV structure, create tables, and insert data into PostgreSQL with minimal effort. Just drop your CSV files into a folder, and 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 Configurations โ Uses .env for secure 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
โ โโโ db_utils.py # PostgreSQL connection utilities
โ โโโ exception.py # Custom exception handling
โ โโโ logger.py # Logging setup
โโโ scripts/ # Command-line scripts
โ โโโ ingest.py # Main ingestion script
โโโ 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 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 loader
pip install -r requirements.txt
โ Usage
1๏ธโฃ Set Up Your Environment
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
2๏ธโฃ Using the CLI
Place your CSV files inside the csv_files/ directory and run the ingestion script:
python scripts/ingest.py
Alternatively, if using the CLI command:
loader --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.process_csv import CSVProcessor
# Define the folder where CSV files are stored
csv_folder = "csv_files/"
# Initialize the processor
processor = CSVProcessor(csv_folder)
# Start the ingestion process
processor.process_files()
๐งช Testing
Run unit tests using:
pytest tests/
๐ 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
๐ 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.2.tar.gz.
File metadata
- Download URL: havinosh_data_loader-0.0.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
128453e5f0c78d4746c434d0ea548478613cbcee63935032188a30f9ef97a48d
|
|
| MD5 |
2f2938cf7894ce2717c159b6cfc397ac
|
|
| BLAKE2b-256 |
dcfa42b177c0fb4720701e648142dfa3a149f3ad782a8e6e85fdda54f26dcaa2
|
File details
Details for the file havinosh_data_loader-0.0.2-py3-none-any.whl.
File metadata
- Download URL: havinosh_data_loader-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.7 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 |
ae2ef33ebd075ee8eb9d2da3da7b60d155a313d80a841e6e9932dcbdbca212bd
|
|
| MD5 |
ad317d40d19c7968f3e2c81f0c13c548
|
|
| BLAKE2b-256 |
d4bb97d1c696b6042226f8d6d751f54868f10f43b761f1cd2a1aac7bbe28117b
|