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
Metadata
Release files for pycsv2sqlite 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pycsv2sqlite-0.1.0.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycsv2sqlite-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / pycsv2sqlite-0.1.0.tar.gz
| Download URL | pycsv2sqlite-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bcc1a5a9719de313c5cf2be9d32e2bf23e9520ea49e597aad73b14c2a3f5dd44
|
|
BLAKE2b-256 checksum How to use checksums |
34120617271c8c6a52230c7973409b3a592007b7d68d4c56ee6f57ea2b013da3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.25
|
Release files / pycsv2sqlite-0.1.0-py3-none-any.whl
| Download URL | pycsv2sqlite-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8ac91438035c6596e2aae0d49c164411467d35505a96ec768044316662f48cc
|
|
BLAKE2b-256 checksum How to use checksums |
a1add089aa18b4c08b67ce56f69d0df80d9c8c08029317ec370d425dc445a2f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.25
|