๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
Book a DemoInstallSign in
Socket

csv-graphql-cli

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-graphql-cli

๐Ÿ“ A beautiful CLI tool for ingesting CSV files into PostgreSQL and serving data via GraphQL

1.0.5
PyPI
Maintainers
1

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

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-26 at 7 56 13โ€ฏAM Screenshot 2025-05-26 at 8 19 37โ€ฏAM Screenshot 2025-05-25 at 9 33 31โ€ฏPM Screenshot 2025-05-25 at 9 33 41โ€ฏPM Screenshot 2025-05-25 at 9 33 58โ€ฏPM Screenshot 2025-05-25 at 9 34 21โ€ฏPM Screenshot 2025-05-25 at 9 34 44โ€ฏ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

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)

CommandDescription
python -m src.cliMain CLI interface
python -m src.cli init-dbInitialize database
python -m src.cli ingestIngest CSV files
python -m src.cli serveStart GraphQL server
python -m src.cli previewPreview table data
python -m src.cli tablesList available tables
python -m src.cli config-infoShow current configuration

All Available Commands Summary

MethodCommandDescription
PyPI PackagecsvgqlMain CLI interface (shows all commands)
PyPI Packagecsvgql init-dbInitialize database
PyPI Packagecsvgql ingestIngest CSV files
PyPI Packagecsvgql serveStart GraphQL server
PyPI Packagecsvgql previewPreview table data
PyPI Packagecsvgql tablesList available tables
PyPI Packagecsvgql config-infoShow current configuration
Developmentpython csvgql.pyMain CLI interface
Developmentpython csvgql.py init-dbInitialize database
Developmentpython -m src.cliMain CLI interface
Developmentpython -m src.cli init-dbInitialize 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

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

Keywords

csv

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts