How to set templating within SQL files in PyCharm?
In our project, we use format string templates within SQL script files, which are formatted using psycopg's SQL formatters, e.g. select_value.sql:
SELECT
column
FROM table
WHERE column = {value};Obviously, this is not SQL compliant, and PyCharm flags it as an error.
Is there a way I can tell PyCharm to treat such blocks as valid substitution blocks?
I have tried the following, with no success:
- Using the pattern: “\{[^}]+\}” in: Tools→Database→Query Execution→User Parameters
- In Languages & Frameworks→Template Languages Add SQL as a file type, and setting the Template language to each of the available options (Chameleon, Django, and Jinja2)
Are there any other options I can try?
请先登录再写评论。
Hi,
If the issue is only with the
{value}highlighting, adding the\{[^}]+\}pattern should help. Have you enabled it in scripts and for all languages?I had, but I also had a faulty installation of PyCharm.
After re-installing PyCharm, the pattern worked exactly as shown, thanks.