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 plan samples and aggregate them
logical_plan = logical_planner.plan(
    natural_language_query="What was the average number of piglets per week for Q4 2025?",
    num_samples=3,
)

# print the aggregated logical plan
for i, step in enumerate(logical_plan.logical_steps):
    print(f"Step {i + 1}: ")
    print(step)
>>> 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 that can generate one plan or sample multiple plans and aggregate them with num_samples.

Plan aggregation is available through LogicalPlans.aggregate().

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.5.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.5-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: piglets-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 5e4b882b4050fe7a77c6ee19d5f70dd544c3d3c22070d420a9d9854ff756f051
MD5 c7c9e111bd73d2be05838645ebb8b045
BLAKE2b-256 7dad63cf8c5725466580d225ceb18b3875c8c2b0ee87fa36a0b9f18cbed3a42a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: piglets-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9845596f1eff6f357fd54eade39f9ac7cce504bbf2e82a1a596f769e86c90195
MD5 14e4c7178f9621fd94cb5fe7fd10c914
BLAKE2b-256 3c1561033bb5fd7252e2336ae46a701191a76632bcbb308f82b8d5f4af3d1cb1

See more details on using hashes here.

Provenance

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