pygments.lexers.sql

Lexers for various SQL dialects and related interactive sessions.

Postgres specific lexers:

PostgresLexer

A SQL lexer for the PostgreSQL dialect. Differences w.r.t. the SQL lexer are:

  • keywords and data types list parsed from the PG docs (run the _postgres_builtins module to update them);
  • Content of $-strings parsed using a specific lexer, e.g. the content of a PL/Python function is parsed using the Python lexer;
  • parse PG specific constructs: E-strings, $-strings, U&-strings, different operators and punctuation.
PlPgsqlLexer
A lexer for the PL/pgSQL language. Adds a few specific construct on top of the PG SQL lexer (such as <<label>>).
PostgresConsoleLexer

A lexer to highlight an interactive psql session:

  • identifies the prompt and does its best to detect the end of command in multiline statement where not all the lines are prefixed by a prompt, telling them apart from the output;
  • highlights errors in the output and notification levels;
  • handles psql backslash commands.

The tests/examplefiles contains a few test files with data to be parsed by these lexers.

copyright:Copyright 2006-2013 by the Pygments team, see AUTHORS.
license:BSD, see LICENSE for details.
class pygments.lexers.sql.PostgresLexer(**options)[source]

Lexer for the PostgreSQL dialect of SQL.

New in Pygments 1.5.

class pygments.lexers.sql.PlPgsqlLexer(**options)[source]

Handle the extra syntax in Pl/pgSQL language.

New in Pygments 1.5.

class pygments.lexers.sql.PostgresConsoleLexer(**options)[source]

Lexer for psql sessions.

New in Pygments 1.5.

class pygments.lexers.sql.SqlLexer(**options)[source]

Lexer for Structured Query Language. Currently, this lexer does not recognize any special syntax except ANSI SQL.

class pygments.lexers.sql.MySqlLexer(**options)[source]

Special lexer for MySQL.

class pygments.lexers.sql.SqliteConsoleLexer(**options)[source]

Lexer for example sessions using sqlite3.

New in Pygments 0.11.

Project Versions

This Page