Simple API
The simple API provides high-level functions for linting, fixing, and parsing SQL strings.
Classes
APIParsingError
An exception which holds a set of violations.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
violations | list[SQLBaseError] | — | |
args | Any | — |
Functions
fix
python
fix(
sql,
dialect=None,
rules=None,
exclude_rules=None,
config=None,
config_path=None,
fix_even_unparsable=None
) → strFix a SQL string.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
sql | str | — | The SQL to be fixed. |
dialect | `str | None` | None |
rules | `list[str] | None` | None |
exclude_rules | `list[str] | None` | None |
config | `fluffconfig.FluffConfig | None` | None |
config_path | `str | None` | None |
fix_even_unparsable | `bool | None` | None |
Returns:
str — str for the fixed SQL if possible.
get_simple_config
python
get_simple_config(
dialect=None,
rules=None,
exclude_rules=None,
config_path=None
) → fluffconfig.FluffConfigGet a config object from simple API arguments.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
dialect | `str | None` | None |
rules | `list[str] | None` | None |
exclude_rules | `list[str] | None` | None |
config_path | `str | None` | None |
Returns:
fluffconfig.FluffConfig — See return type above
lint
python
lint(
sql,
dialect=None,
rules=None,
exclude_rules=None,
config=None,
config_path=None
) → list[dict[str, Any]]Lint a SQL string.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
sql | str | — | The SQL to be linted. |
dialect | `str | None` | None |
rules | `list[str] | None` | None |
exclude_rules | `list[str] | None` | None |
config | `fluffconfig.FluffConfig | None` | None |
config_path | `str | None` | None |
Returns:
list[dict[str, Any]] — list[dict[str, Any]] for each violation found.
parse
python
parse(
sql,
dialect=None,
config=None,
config_path=None
) → dict[str, Any]Parse a SQL string.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
sql | str | — | The SQL to be parsed. |
dialect | `str | None` | None |
config | `fluffconfig.FluffConfig | None` | None |
config_path | `str | None` | None |
Returns:
dict[str, Any] — Dict[str, Any] JSON containing the parsed structure.
Note: In the case of multiple potential variants from the raw source file only the first variant is returned by the simple API. For access to the other variants, use the underlying main API directly.