Skip to content

aali-22/data2sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

data2sql

A flexible CLI tool to convert ,preferably, data (JSON/CSV) into SQL tables.

Installation

pip install -r requirements.txt

Usage

Basic usage:

python main.py convert --file input.json --table player_stats

Options:

  • --file: Input JSON or CSV file (required)
  • --format: Input format (json/csv, auto-detected if not specified)
  • --table: Name of the SQL table to create (required)
  • --output: Output file (.sql) or database URL (e.g. sqlite:///out.db)
  • --preview: Preview the inferred schema
  • --interactive: Interactively confirm or modify field types

Examples:

  1. Preview schema before conversion:
python main.py convert --file stats.json --table player_stats --preview
  1. Write to SQLite database:
python main.py convert --file stats.csv --table match_stats --output sqlite:///football.db
  1. Interactive schema modification:
python main.py convert --file player.json --table players --interactive

Features

  • Automatic schema inference from JSON/CSV data
  • Support for basic SQL types (TEXT, INTEGER, REAL, DATE, BOOLEAN)
  • Interactive schema modification
  • Output to .sql file or direct database insertion(PostgreSQL/
  • Cross-platform support

Development

The codebase is structured as follows:

  • cli.py: Command-line interface using Click
  • core.py: Core data processing and SQL generation
  • utils.py: Utility functions for validation and type inference

License

MIT

About

CLI tool to convert CSV/JSON into SQL tables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages