Skip to main content

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

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

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycsv2sqlite-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

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

Hashes for pycsv2sqlite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bcc1a5a9719de313c5cf2be9d32e2bf23e9520ea49e597aad73b14c2a3f5dd44
MD5 c271db2426de12e86862002d053c723b
BLAKE2b-256 34120617271c8c6a52230c7973409b3a592007b7d68d4c56ee6f57ea2b013da3

See more details on using hashes here.

File details

Details for the file pycsv2sqlite-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pycsv2sqlite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8ac91438035c6596e2aae0d49c164411467d35505a96ec768044316662f48cc
MD5 320142a100576240e27948cfd7bcd478
BLAKE2b-256 a1add089aa18b4c08b67ce56f69d0df80d9c8c08029317ec370d425dc445a2f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page