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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8212e7d3a279c20dd5796ba0c29beecfa3d4dee14794f3eb1d54e65dd33e9bf
|
|
| MD5 |
bf7ded9f4f976bb0db7267f08b091521
|
|
| BLAKE2b-256 |
48e8b9e9c8a8d77a578748599c8d15463acc693b473cf38c3c1c6ea8f810dcd2
|
Provenance
The following attestation bundles were made for piglets-0.1.4.tar.gz:
Publisher:
publish.yml on mportdata/piglets
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piglets-0.1.4.tar.gz -
Subject digest:
b8212e7d3a279c20dd5796ba0c29beecfa3d4dee14794f3eb1d54e65dd33e9bf - Sigstore transparency entry: 1280897209
- Sigstore integration time:
-
Permalink:
mportdata/piglets@38e7aa7498041b9cf5778cfb382be9b26a4c9a49 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/mportdata
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@38e7aa7498041b9cf5778cfb382be9b26a4c9a49 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d0ced3367ab21fe1a0b5f0112bec128e1f581a95c44bafc2826edbd976923ee
|
|
| MD5 |
be728bbe5b7da64209ad8b5684fce0e0
|
|
| BLAKE2b-256 |
365b4092e479247b4f8ca35c5b4d7b65e5d0abbf3ecaaa3e439fe5bc109b4e3f
|
Provenance
The following attestation bundles were made for piglets-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on mportdata/piglets
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piglets-0.1.4-py3-none-any.whl -
Subject digest:
3d0ced3367ab21fe1a0b5f0112bec128e1f581a95c44bafc2826edbd976923ee - Sigstore transparency entry: 1280897220
- Sigstore integration time:
-
Permalink:
mportdata/piglets@38e7aa7498041b9cf5778cfb382be9b26a4c9a49 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/mportdata
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@38e7aa7498041b9cf5778cfb382be9b26a4c9a49 -
Trigger Event:
push
-
Statement type: