๐ A beautiful CLI tool for ingesting CSV files into PostgreSQL and serving data via GraphQL
Project description
๐ GraphQL CSV Ingest
____ _ ____ _ ____ ______ __ ___ _
/ ___|_ __ __ _ _ __ | |__ / __ \| | / ___/ ___\ \ / / |_ _|_ __ __ _ __| |_
| | _| '__/ _` | '_ \| '_ \| | | | | | | \___ \\ \ / / | || '_ \ / _` |/ _` (_)
| |_| | | | (_| | |_) | | | | |__| | |___ | |___ ___) |\ V / | || | | | (_| | (_| |_
\____|_| \__,_| .__/|_| |_|\___\_\_____| \____|____/ \_/ |___|_| |_|\__, |\__,_(_)
|_| |___/
Transform your CSV data into powerful GraphQL APIs in minutes!
๐ Documentation โข ๐ Quick Start โข ๐ป Examples โข ๐ค Contributing
โจ Features
๐ฅ Professional Data Pipeline in Your Terminal
- ๐ Beautiful CLI: Fun ASCII art and colorful interface
- ๐ Smart CSV Ingestion: Automatic schema detection and type inference
- ๐ PostgreSQL Integration: Seamless database operations
- ๐ GraphQL API: Modern, flexible data querying
- ๐ FastAPI Server: High-performance async web server
- ๐ฏ Multiple Entry Points: Multiple CLI commands for convenience
- ๐ ๏ธ Developer Friendly: Type hints, comprehensive error handling
- ๐ฆ Easy Installation: Available on PyPI with all dependencies
๐ Quick Start
Installation
# ๐ Install from PyPI (Recommended)
pip install csv-graphql-cli
# ๐ง Or install in a virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install csv-graphql-cli
# ๐ ๏ธ Development installation from source
git clone https://github.com/cjanowski/graphql-ingest.git
cd graphql-ingest
pip install -e ".[dev]"
Quick Start - Method 1: Using Installed Commands (Recommended)
After running pip install csv-graphql-cli:
# 1๏ธโฃ Show the main interface and available commands
csvgql
# 2๏ธโฃ Initialize database connection
csvgql init-db
# 3๏ธโฃ Ingest your CSV data
csvgql ingest -f data/sample_data.csv -t employees
# 4๏ธโฃ Preview your data
csvgql preview -t employees
# 5๏ธโฃ Start GraphQL server
csvgql serve
# 6๏ธโฃ Query at http://localhost:8000/graphql
Quick Start - Method 2: Using Wrapper Script
Use the convenient wrapper script (csvgql.py) if you prefer not to install:
# Navigate to project directory
cd graphql-ingest
# 1๏ธโฃ Show the main interface and available commands
python csvgql.py
# 2๏ธโฃ Initialize database connection
python csvgql.py init-db
# 3๏ธโฃ Ingest your CSV data
python csvgql.py ingest -f data/sample_data.csv -t employees
# 4๏ธโฃ Preview your data
python csvgql.py preview -t employees
# 5๏ธโฃ Start GraphQL server
python csvgql.py serve
# 6๏ธโฃ Query at http://localhost:8000/graphql
Quick Start - Method 3: Direct Module Usage
For development, you can also run directly from source:
# Navigate to project directory
cd graphql-ingest
# Run CLI directly from source
python -m src.cli
# Or individual commands
python -m src.cli init-db
python -m src.cli ingest -f data/sample_data.csv -t employees
python -m src.cli serve
๐ฌ Demo
Demo video coming soon - showing the CLI interface in action!
๐ Example Workflow
# Using installed package (after pip install csv-graphql-cli)
csvgql # Show main interface
csvgql init-db # Initialize database
csvgql ingest -f data.csv -t users # Ingest CSV data
csvgql preview -t users # Preview the data
csvgql serve # Start GraphQL server
# OR using wrapper script (development)
python csvgql.py # Show main interface
python csvgql.py init-db # Initialize database
python csvgql.py ingest -f data.csv -t users # Ingest CSV data
python csvgql.py preview -t users # Preview the data
python csvgql.py serve # Start GraphQL server
๐ง CLI Commands
Method 1: Using Installed Package (Recommended)
After running pip install csv-graphql-cli:
csvgql # Show main interface
csvgql init-db # Initialize database
csvgql ingest -f data.csv -t table # Ingest CSV
csvgql serve # Start GraphQL server
csvgql preview -t table # Preview table data
csvgql tables # List tables
csvgql config-info # Show configuration
Method 2: Using the Wrapper Script
If you prefer not to install the package:
# Navigate to project directory
cd graphql-ingest
# Use the wrapper script
python csvgql.py # Show main interface
python csvgql.py init-db # Initialize database
python csvgql.py ingest -f data.csv -t table # Ingest CSV
python csvgql.py serve # Start GraphQL server
python csvgql.py preview -t table # Preview table data
python csvgql.py tables # List tables
python csvgql.py config-info # Show configuration
Method 3: Direct Module Execution (Development)
| Command | Description |
|---|---|
python -m src.cli |
Main CLI interface |
python -m src.cli init-db |
Initialize database |
python -m src.cli ingest |
Ingest CSV files |
python -m src.cli serve |
Start GraphQL server |
python -m src.cli preview |
Preview table data |
python -m src.cli tables |
List available tables |
python -m src.cli config-info |
Show current configuration |
All Available Commands Summary
| Method | Command | Description |
|---|---|---|
| PyPI Package | csvgql |
Main CLI interface (shows all commands) |
| PyPI Package | csvgql init-db |
Initialize database |
| PyPI Package | csvgql ingest |
Ingest CSV files |
| PyPI Package | csvgql serve |
Start GraphQL server |
| PyPI Package | csvgql preview |
Preview table data |
| PyPI Package | csvgql tables |
List available tables |
| PyPI Package | csvgql config-info |
Show current configuration |
| Development | python csvgql.py |
Main CLI interface |
| Development | python csvgql.py init-db |
Initialize database |
| Development | python -m src.cli |
Main CLI interface |
| Development | python -m src.cli init-db |
Initialize database |
๐ GraphQL Queries
List Tables
{
tables {
name
columns {
name
type
}
}
}
Query Data
{
tableData(tableName: "employees", limit: 10) {
data
total
}
}
Ingest CSV via API
mutation {
ingestCsv(file: "new_data.csv", tableName: "products") {
success
message
rowsInserted
}
}
๐ ๏ธ Configuration
Create .env file in the project root:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_database
DB_USER=your_username
DB_PASSWORD=your_password
# Server Configuration
SERVER_HOST=0.0.0.0
SERVER_PORT=8000
DEBUG=false
You can also copy the example configuration:
cp config/env.example .env
๐ Project Structure
graphql-ingest/
โโโ ๐ฆ src/ # Main application code
โ โโโ cli.py # Command-line interface
โ โโโ config.py # Configuration management
โ โโโ database.py # Database operations
โ โโโ graphql_schema.py # GraphQL schema definition
โ โโโ server.py # FastAPI server
โโโ ๐งช tests/ # Test suite
โ โโโ test_basic.py # Basic functionality tests
โ โโโ integration_test_examples.py
โโโ ๐ examples/ # Usage examples
โโโ ๐ docs/ # Documentation
โโโ ๐ณ docker/ # Docker configuration
โโโ ๐ data/ # Sample data files
โ โโโ sample_data.csv # Test data
โ โโโ test_data_large.csv # Larger test dataset
โโโ โ๏ธ config/ # Configuration files
โ โโโ env.example # Environment template
โ โโโ setup.cfg # Setup configuration
โ โโโ MANIFEST.in # Package manifest
โโโ ๐ ๏ธ tools/ # Build and development tools
โ โโโ setup.py # Package setup script
โ โโโ coverage.xml # Coverage reports
โโโ ๐ .github/ # GitHub workflows
โโโ ๐ requirements/ # Dependency management
โโโ ๐ CONTRIBUTE.md # Contribution guidelines
โโโ ๐ CHANGELOG.md # Change log
โโโ ๐ QUICKSTART.md # Quick start guide
โโโ ๐ README.md # Project overview
๐งช Testing
Setup Testing Environment
# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate
# Install with development dependencies
pip install -e ".[dev]"
Run Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=src
# Run with verbose output
pytest -v
# Run specific test file
pytest tests/test_basic.py
๐ณ Docker Support
# Build and run with Docker
docker-compose up
# Or use the Dockerfile directly
docker build -t csv-graphql-cli .
docker run -p 8000:8000 csv-graphql-cli
๐ Installation Options
Option 1: Install from PyPI (Recommended) ๐
pip install csv-graphql-cli
Option 2: Install in Virtual Environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install csv-graphql-cli
Option 3: Development Setup
git clone https://github.com/cjanowski/graphql-ingest.git
cd graphql-ingest
pip install -e ".[dev]"
๐ Requirements
- Python 3.9 or higher
- PostgreSQL database
- Modern terminal with Unicode support
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with Strawberry GraphQL
- Powered by FastAPI
- CLI beauty by Click
- Data processing by Pandas
Made with โค๏ธ and lots of ๐๐๐!
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
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 csv_graphql_cli-1.0.3.tar.gz.
File metadata
- Download URL: csv_graphql_cli-1.0.3.tar.gz
- Upload date:
- Size: 241.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e87645dddc4aa5b116bacfa4d82efd33a441b7c5f4855bdef9085ea590d3c380
|
|
| MD5 |
d1cf266e9020dca1ca649e95d51f1d42
|
|
| BLAKE2b-256 |
a1170968343e8eca293dc558b1e2904a7f59944987a02b7096a79e6db9a91650
|
File details
Details for the file csv_graphql_cli-1.0.3-py3-none-any.whl.
File metadata
- Download URL: csv_graphql_cli-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7b7d2840af2da39323acd801c45b2fc907a521b1f515aaeaefe47f307b24705
|
|
| MD5 |
866d7c04d43d45c737d432bf34e56634
|
|
| BLAKE2b-256 |
687c3440aa195b8881138e5a2c2a05ef922d56fe84ef8cc277a79062162bf6ca
|