Skip to main content

pycsv2sqlite

🗄️ A fast Python utility for converting CSV/TSV files to SQLite databases with automatic schema detection

Python Support License

✨ 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

  1. Clone the repository
git clone https://github.com/fxyzbtc/pycsv2sqlite.git
cd pycsv2sqlite
  1. Create and activate virtual environment
uv venv .venv
.venv\Scripts\activate  # Windows
source .venv/bin/activate  # Unix
  1. 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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License.

🙏 Acknowledgments

  • Pandas for data processing
  • Typer for the CLI interface
  • SQLite for database operations

📞 Support


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)

Source distribution for pycsv2sqlite 0.1.0
File Size Uploaded
pycsv2sqlite-0.1.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycsv2sqlite 0.1.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page