Skip to main content

Format embedded sql (squeel) in python source code files

Project description

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.

Running it might change files on your system. I recommend checking your changes into git before running this tool in case it explodes.

Requirements

pgFormatter if using the default format strategy pg_format

Install

pip install squeel

Usage

See squeel -h

Example:

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

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

squeel-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

squeel-1.0.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file squeel-1.0.1.tar.gz.

File metadata

  • Download URL: squeel-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.11.0

File hashes

Hashes for squeel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bef95415bfaaea1d614972be9b09e3451ca93a5bf9d2aeea6b95714f07e1dc8b
MD5 3c9f4df70df41fab2403b66394c4574b
BLAKE2b-256 bb30224b45056091f0f331e01230b27fcc7945fbc758bbe267388b952e99997a

See more details on using hashes here.

File details

Details for the file squeel-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: squeel-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.11.0

File hashes

Hashes for squeel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cad9bc8bd14f2288617d298f0f425e000e04992bb6adf5f06c13b1bd08091d9e
MD5 1ac94de0fa072e498fab77dae5ae39af
BLAKE2b-256 0e656907fb0412883a4cd2a988a1d14cf99b0235002601fe63455d2a364a736f

See more details on using hashes here.

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