This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Use this Pygments plugin alongside your usual SQL lexer and any output formatter to have your SQL queries reformatted for improved readability.

This filter modifies the stream of tokens that Pygments produces by inserting whitespace at key points to make the structure of the query more obvious.

Usage

For programmatic usage, add the filter to your lexer before highlighting:

from pygments import highlight, lexers, formatters
from pygments_pprint_sql import SqlFilter

lexer = lexers.MySqlLexer()
lexer.add_filter(SqlFilter())
print highlight(text, lexer, formatters.TerminalFormatter())

This plugin is also compatible with the pygmentize CLI tool, via the -F option:

pygmentize -F pprint-sql script.sql

Notes

DDL statements like CREATE and ALTER are left unformatted because formatting them reliably would be a significant undertaking, especially for all flavours of SQL.

I’ve done my testing with queries from an application I work on that uses MySQL. In general it should transfer nicely to other RDBMS but I can make no guarantees.

Patches always welcome, provided they come with test cases!

Alternatives

  • SQLParse is a standalone parser and formatter package with some nice options for customizing how formatting occurs.
Release History

Release History

0.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pygments-pprint-sql-0.1.0.tar.gz (4.8 kB) Copy SHA256 Checksum SHA256 Source Oct 19, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting