Render SQL Template file using sqlfluff API

404 Views Asked by At

Is there any way to render a sql template file using the sqlfluff API.

Currently I can render using the command:

sqlfluff render -d <dialect> some_template.sql 

Is there any way for me to switch from above command to python API? (In addition, after running the sqlfluff lint command in the ci/cd code, are the sql template files changed (apply jinja template)) Sorry for my English, thanks.

1

There are 1 best solutions below

0
On

The CLI functions can be found here, which includes render:
https://github.com/sqlfluff/sqlfluff/blob/main/src/sqlfluff/cli/commands.py#L1116

The python API currently only seems to contain .lint(), .fix() and .parse() and not .render(): https://github.com/sqlfluff/sqlfluff/blob/main/src/sqlfluff/api/simple.py#L59