Skip to content

RIG

RIG is a CLI tool that automates the creation of database integration tests for your Python applications.

Core trick

Feeds Python AST and SQL schema to Gemini, which writes pytest files that run against real Dockerized databases via testcontainers.

Tags

Description

RIG is a CLI tool that automates the creation of database integration tests for your Python applications. It uses Google's Gemini AI to analyse your Data Access Object (DAO) code and SQL schema, generating complete, runnable pytest files backed by testcontainers.
DarshanVaishnav/rig★ 00 forksPythonMITCreated Dec 13, 2025 · last push Dec 13, 2025

README excerpt

# Rig: Automated Database Integration Tests

Rig is a CLI tool that automates the creation of database integration tests for your Python applications. It uses Google's Gemini AI to analyze your Data Access Object (DAO) code and SQL schema, generating complete, runnable `pytest` files backed by `testcontainers`.

## Features

-   **Automated Test Generation**: Generates `pytest` code tailored to your specific DAO logic.
-   **Real Database Fixtures**: Uses `testcontainers` to spin up real Docker containers (Postgres, MySQL, etc.) for tests.
-   **Context-Aware**: Analyzes your Python code (AST) and SQL schema to understand your data model.
-   **Configurable**: Supports different database dialects and test frameworks via `rig.toml`.

## Installation

### Prerequisites
-   Python 3.12+
-   Docker (for running the generated tests)
-   Google Gemini API Key

### Install from Source
```bash
git clone https://github.com/yourusername/rig.git
cd rig
pip install -e .
```

## Configuration

1.  **Initialize the Project**:
    Run `rig init` in your project root. This creates a `rig.toml` file.

    ```bash
    rig init
    # or
    python3 -m rig.cli.main init
    ```

2.  **Set API Key**:
    Export your Gemini API key as an environment variable.

    ```bash
    export GEMINI_API_KEY="your-api-key"
    ```

3.  **Customize `rig.toml`** (Optional):
    ```toml
    schema_path = "schema.sql"
    db_dialect = "postgres"  # or "mysql"
    test_framework = "pytest"
    ```

## Usage

### 

Team