read csv/tsv like file/files and produce sqlite3 db file
Project description
pycsv2sqlite
🗄️ A fast Python utility for converting CSV/TSV files to SQLite databases with automatic schema detection
✨ Features
- 🚀 Fast CSV/TSV import using Pandas
- 📁 Process single files or entire directories
- 🗄️ Automatic SQLite schema creation
- 🔄 Smart type mapping from Pandas to SQLite
- 📊 Detailed import statistics
- 🗜️ Support for gzipped files
- 🎯 Simple CLI interface with Typer
📦 Installation
Using pip
pip install pycsv2sqlite
Using uv (Recommended)
uv is a blazing-fast Python package installer:
# Install uv
pip install uv
# Install pycsv2sqlite using uv
uv pip install pycsv2sqlite
🚀 Quick Start
Command Line Usage
# Basic usage
pycsv2sqlite import-data data.csv
# Import TSV file
pycsv2sqlite import-data data.tsv --delimiter="\t"
# Import directory of CSVs
pycsv2sqlite import-data ./data/
Python Module Usage
python -m pycsv2sqlite import-data [options] INPUT_PATH
🎛️ Configuration Options
| Option | Description | Default |
|---|---|---|
--delimiter |
Field delimiter in input files | , |
--no-has-headers |
Files don't have headers | False |
--db-file |
Output SQLite database name | YYYYMMDD_HHMMSS.sqlite3 |
🛠️ Development
Setup Development Environment
- Clone the repository
git clone https://github.com/fxyzbtc/pycsv2sqlite.git
cd pycsv2sqlite
- Create and activate virtual environment
uv venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # Unix
- Install development dependencies
uv pip install -r requirements-dev.txt
Running Tests
pytest
pytest --cov=pycsv2sqlite tests/
Code Style
# Format code
black .
# Lint code
ruff check .
# Type checking
mypy .
📝 Example Output
SQLite Table Schema for data:
CREATE TABLE "data" (
"id" INTEGER,
"name" TEXT,
"value" REAL,
"timestamp" TIMESTAMP
)
Statistics:
- Records added to table: 1000
- Total records in table: 1000
- Columns: 4
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License.
🙏 Acknowledgments
📞 Support
- 📫 Report issues on GitHub Issues
- 💬 Ask questions in Discussions
- 📚 Read the documentation
Made with ❤️ using Python
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
pycsv2sqlite-0.1.0.tar.gz
(5.9 kB
view details)
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 pycsv2sqlite-0.1.0.tar.gz.
File metadata
- Download URL: pycsv2sqlite-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcc1a5a9719de313c5cf2be9d32e2bf23e9520ea49e597aad73b14c2a3f5dd44
|
|
| MD5 |
c271db2426de12e86862002d053c723b
|
|
| BLAKE2b-256 |
34120617271c8c6a52230c7973409b3a592007b7d68d4c56ee6f57ea2b013da3
|
File details
Details for the file pycsv2sqlite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pycsv2sqlite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8ac91438035c6596e2aae0d49c164411467d35505a96ec768044316662f48cc
|
|
| MD5 |
320142a100576240e27948cfd7bcd478
|
|
| BLAKE2b-256 |
a1add089aa18b4c08b67ce56f69d0df80d9c8c08029317ec370d425dc445a2f2
|