Skip to main content

๐Ÿ“ 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!

PyPI version Python Version PyPI downloads License: MIT Code style: black

๐Ÿ“– 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! Screenshot 2025-05-25 at 6 47 00โ€ฏPM Screenshot 2025-05-25 at 6 47 08โ€ฏPM Screenshot 2025-05-25 at 6 47 18โ€ฏPM Screenshot 2025-05-25 at 6 47 33โ€ฏPM

๐Ÿ“Š 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


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

csv_graphql_cli-1.0.1.tar.gz (240.4 kB view details)

Uploaded Source

Built Distribution

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

csv_graphql_cli-1.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file csv_graphql_cli-1.0.1.tar.gz.

File metadata

  • Download URL: csv_graphql_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 240.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for csv_graphql_cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a64031f6eb01adf0a04124d83cc3dea5e4b35bb178a1a5dbc0e3835134d07c66
MD5 807cc1e41470ff310da4cfce07f535e6
BLAKE2b-256 8d8b4df478ace9b1fb82dfdfd06d48c4d098570e742f36baaa08dd7ab9cd3339

See more details on using hashes here.

File details

Details for the file csv_graphql_cli-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for csv_graphql_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54d65c90ac7c7716bd411eaa28b683689740a5862c64fe5324dc94d6eeabdc9b
MD5 9c642f5b2b239ec0d77a2d87566049d3
BLAKE2b-256 fabc652de7cd4ec3c80105b6497138da350b684db8d2f5ef3d9dda497a728931

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