Skip to main content

A modular text-to-SQL toolkit.

Project description

🐷 piglets

A modular, pre-1.0 library of text-to-SQL planning 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)):
    print(f"Logical Plan {i + 1}: ")
    steps = 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.3.tar.gz (5.8 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.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: piglets-0.1.3.tar.gz
  • Upload date:
  • Size: 5.8 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.3.tar.gz
Algorithm Hash digest
SHA256 ebdc160a3d8c598b4739f7a4c31fbe3699f83a1a3572355bea8aace444e67c3f
MD5 71ea821bec899b0d8223a98522e19473
BLAKE2b-256 7a9c0db22a75f871285c9bb4f59f4ef5c0de59005c89c13c856dc01e20d58ecb

See more details on using hashes here.

Provenance

The following attestation bundles were made for piglets-0.1.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: piglets-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e4e2f590892bfbd362a33f06476bf08fb55705013229cd420be78b0c2412b790
MD5 f80b2541333a3e66cf3490b479113377
BLAKE2b-256 54b6422b5bea50d074ad6c29fa3b1634981fd3f660767e5543588b6a0a9f11be

See more details on using hashes here.

Provenance

The following attestation bundles were made for piglets-0.1.3-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