Skip to main content

Squeel

Format embedded sql (squeel) in python source code files.

Uses treesitter to query python strings inside the python files starting with a sql comment -- sql. Then formats the sql matching strings with the selected formatter, by default pg_format, and writes them back to the files.

Uses one of sqlparse or pg_format to format the SQL within the python code.

Warning

This is an experimental tool.

Its purpose is to change files on your system. I recommend checking your changes into git before running this tool in case it explodes. Ensure you give it the appropriate root_folder and glob patterns so it doesn't change files on your system that you don't want changed. No changes will be written to any files unless you supply the --change flag. The default behaviou is to dry run.

$ squeel .      
-- DRY RUN -- No actual changes will be made.
Found 42 files matching the glob pattern.
Would format 1 files:
test/data/test-1.py: 1 sql strings to be changed, 0 unchanged.

Requirements

pgFormatter if using the default format strategy pg_format

Install

pip install squeel

Usage

See squeel -h

squeel -h
usage: squeel [-h] [--change] [--glob GLOB] [--format_strategy FORMAT_STRATEGY] root_folder

Squeel

positional arguments:
  root_folder           The root folder to look for files to format

options:
  -h, --help            show this help message and exit
  --change              Dry run
  --glob GLOB           Glob pattern
  --format_strategy FORMAT_STRATEGY
                        Format strategy, one of 'pg_format' or 'sqlparse' (default pg_format)

Example run:

squeel --glob *.py --format_strategy sqlparse --change src

Metadata

Release files for squeel 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for squeel 1.1.0
File Size Uploaded Provenance Actions
squeel-1.1.0.tar.gz 4.7 kB Without provenance Details for squeel-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for squeel 1.1.0
File Interpreter ABI Platform Actions
squeel-1.1.0-py3-none-any.whl Python 3 none any Details for squeel-1.1.0-py3-none-any.whl

Total release size: 10.9 kB

Release files / squeel-1.1.0.tar.gz

Download URL squeel-1.1.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
67ee208a0d45b8f7a7363d7ea5e1ef0e5a7222306cd5b11ea2bedfd9a452ffc0
BLAKE2b-256 checksum
How to use checksums
735278791ddcb4a0001d6c6e67aa80bf42dc79d1c477a4d419a404a75dbda769
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Linux/6.11.0

Release files / squeel-1.1.0-py3-none-any.whl

Download URL squeel-1.1.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8beff558fea02749446c6b6996464b99a4a06cdb1c5cb38c71c5b096e423246c
BLAKE2b-256 checksum
How to use checksums
ac9ba3405e0d08c6abb63ce4488596c85f57754ae433e8659db9b5e3a2fff0b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Linux/6.11.0

Security for squeel 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page