module documentation

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.

Unknown Field: copyright
Copyright 2006-2021 by the Pygments team, see AUTHORS.
Unknown Field: license
BSD, see LICENSE for details.
Class ​My​Sql​Lexer The Oracle MySQL lexer.
Class ​Pl​Pgsql​Lexer Handle the extra syntax in Pl/pgSQL language.
Class ​Postgres​Console​Lexer Lexer for psql sessions.
Class ​Postgres​Lexer Lexer for the PostgreSQL dialect of SQL.
Class ​Rql​Lexer Lexer for Relation Query Language.
Class ​Sqlite​Console​Lexer Lexer for example sessions using sqlite3.
Class ​Sql​Lexer Lexer for Structured Query Language. Currently, this lexer does not recognize any special syntax except ANSI SQL.
Class ​Transact​Sql​Lexer Transact-SQL (T-SQL) is Microsoft's and Sybase's proprietary extension to SQL.
Variable do​_re Undocumented
Variable language​_re Undocumented
Variable line​_re Undocumented
Variable name​_between​_backtick​_re Undocumented
Variable name​_between​_bracket​_re Undocumented
Variable re​_end​_command Undocumented
Variable re​_error Undocumented
Variable re​_message Undocumented
Variable re​_prompt Undocumented
Variable re​_psql​_command Undocumented
Variable sqlite​_prompt​_re Undocumented
Variable tsql​_declare​_re Undocumented
Variable tsql​_go​_re Undocumented
Variable tsql​_variable​_re Undocumented
Class lookahead Wrap an iterator and allow pushing back an item.
Class ​Postgres​Base Base class for Postgres-related lexers.
Class ​Psql​Regex​Lexer Extend the PostgresLexer adding support specific for psql commands.
Function language​_callback Parse the content of a $-string using a lexer
do_re =

Undocumented

language_re =

Undocumented

line_re =

Undocumented

name_between_backtick_re =

Undocumented

name_between_bracket_re =

Undocumented

re_end_command =

Undocumented

re_error =

Undocumented

re_message =

Undocumented

re_prompt =

Undocumented

re_psql_command =

Undocumented

sqlite_prompt_re =

Undocumented

tsql_declare_re =

Undocumented

tsql_go_re =

Undocumented

tsql_variable_re =

Undocumented

def language_callback(lexer, match):

Parse the content of a $-string using a lexer

The lexer is chosen looking for a nearby LANGUAGE or assumed as plpgsql if inside a DO statement and no LANGUAGE has been found.