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!

Python Version 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: pip-installable with all dependencies

๐Ÿš€ Quick Start

Installation

# From source (recommended - package not yet on PyPI)
git clone https://github.com/cjanowski/graphql-ingest.git
cd graphql-ingest
pip install -e .

# For development with all dev dependencies
pip install -e ".[dev]"

# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .

Quick Start - Method 1: Using Installed Commands (Recommended)

After running pip install -e .:

# 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 GIF coming soon - showing the beautiful CLI interface in action!

๐Ÿ“Š Example Workflow

# Using installed commands (after pip install -e .)
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
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 Commands (Recommended)

After running pip install -e .:

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
Installed csvgql Main CLI interface (shows all commands)
Installed csvgql init-db Initialize database
Installed csvgql ingest Ingest CSV files
Installed csvgql serve Start GraphQL server
Installed csvgql preview Preview table data
Installed csvgql tables List available tables
Installed csvgql config-info Show current configuration
Wrapper python csvgql.py Main CLI interface
Wrapper python csvgql.py init-db Initialize database
Direct python -m src.cli Main CLI interface
Direct 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 Source (Recommended)

git clone https://github.com/cjanowski/graphql-ingest.git
cd graphql-ingest
pip install -e .

Option 2: Development Setup

git clone https://github.com/cjanowski/graphql-ingest.git
cd graphql-ingest
pip install -e ".[dev]"

Option 3: Using Virtual Environment (Recommended)

git clone https://github.com/cjanowski/graphql-ingest.git
cd graphql-ingest
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .

๐Ÿ“‹ 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 beautiful ASCII art! ๐ŸŽจ

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-0.1.0.tar.gz (38.5 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-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: csv_graphql_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 38.5 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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 55734cec06fbded47f279a46f291ca834f4bf1c561741fc636b454be2334e00a
MD5 bd16690dc6ea0e5d4be22c9037a341a7
BLAKE2b-256 53f06a3c87114ea5540ab557a0284b9a28a1122767c700c21782af9371c8300d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for csv_graphql_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0de79f5a9a945e65cb24ab6063a953ce3136fc8c14a4845e7cc85c98bee98205
MD5 b6cbf45c788a893f304762e13b4e3a38
BLAKE2b-256 049e7de0c344f85e4ae20f62e7707f976bc7302b2b98c62aa5a07120a39e4493

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