Skip to main content

A modular text-to-SQL toolkit.

Project description

🐷 piglets

A modular library of text-to-SQL tools.

Status

piglets is currently an alpha-stage package. The API is expected to evolve before 1.0.

Get started

Install

venv

pip install piglets

uv

uv add piglets

Example

Use gpt-5.2 to generate 3 logical plans from a natural language query.

Install optional OpenAI dependencies

venv

pip install "piglets[openai]"

uv

uv add "piglets[openai]"
from piglets import LogicalPlanner

# initialise a logical planner
logical_planner = LogicalPlanner('gpt-5.2')

# generate 3 logical plans
logical_plans = logical_planner.parallel_plan(
    natural_language_query="What was the average number of piglets per week for Q4 2025?",
    num_plans=3
)

# print each logical plan
for i in range(len(logical_plans.logical_plans)):
    print(f"Logical Plan {i + 1}: ")
    steps = logical_plans.logical_plans[i].logical_steps
    for j in range(len(steps)):
        print(f"Step {j + 1}: ")
        print(steps[j])
>>> Logical Plan 1:
>>> Step 1:
>>> 1. Identify all piglet birth (or piglet addition) events with their event dates and piglet counts.
>>> Step 2:
>>> 2. Filter the events to the Q4 2025 date range (Oct 1, 2025 through Dec 31, 2025).
>>> Step 3:
>>> 3. Assign each event to a calendar week within that quarter using a consistent week definition (e.g., week starting Monday or Sunday).
...

Current scope

Planning

The first included primitive is a LogicalPlanner that turns a natural-language analytics question into an ordered list of abstract logical steps. The logical planner is an implementation of the planner found in the Apex-SQL paper here.

The LogicalPlanner has a plan method and a parallel_plan method.

Plan aggregation tools are coming soon.

Pruning

Pruning components are planned but not included yet.

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

piglets-0.1.4.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

piglets-0.1.4-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file piglets-0.1.4.tar.gz.

File metadata

  • Download URL: piglets-0.1.4.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for piglets-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b8212e7d3a279c20dd5796ba0c29beecfa3d4dee14794f3eb1d54e65dd33e9bf
MD5 bf7ded9f4f976bb0db7267f08b091521
BLAKE2b-256 48e8b9e9c8a8d77a578748599c8d15463acc693b473cf38c3c1c6ea8f810dcd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for piglets-0.1.4.tar.gz:

Publisher: publish.yml on mportdata/piglets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file piglets-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: piglets-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for piglets-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3d0ced3367ab21fe1a0b5f0112bec128e1f581a95c44bafc2826edbd976923ee
MD5 be728bbe5b7da64209ad8b5684fce0e0
BLAKE2b-256 365b4092e479247b4f8ca35c5b4d7b65e5d0abbf3ecaaa3e439fe5bc109b4e3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for piglets-0.1.4-py3-none-any.whl:

Publisher: publish.yml on mportdata/piglets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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