# Enabling Jinja syntax support in SQL files in PyCharm

**URL:** <https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536>\
**Category:** Show and Tell\
**Tags:** tools, developer-ergonomics\
**Created:** [May 19, 2021, 8:47pm UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536 "2021-05-19T20:47:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![makotonium](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@makotonium](https://discourse.getdbt.com/u/makotonium)\
**Post date:** [May 19, 2021, 8:47pm UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/1 "2021-05-19T20:47:44Z")

</div>

It turns out that you can add Jinja syntax support for dbt model files (.sql) and yaml files in PyCharm Professional Edition or other paid JetBrains products that have multi-language support (Sorry DataGrip users). Here’s how to do it.

**Disclaimers**

1. Unfortunately this is not available in the _Community Edition_ of PyCharm.
2. There is currently a bug in JetBrains IDE that shows a valid SQL with Jinja as having syntax errors if a SQL Dialect is selected to something other than “Generic SQL” (e.g Snowflake) [Link to ticket](https://youtrack.jetbrains.com/issue/PY-48894). The workaround is to either set the global or project SQL Dialect setting under Languages & Frameworks to “Generic SQL”.
3. This is not possible to do in DataGrip

**Steps**

1. Preferences \> Languages and Frameworks \> Template Languages.
2. Select “Jinja2” for the Template Language dropdown at the top,
3. Click on the “+” icon to add SQL (and YAML) to the list. Hit Apply or OK and you are done!

 ![Screen Shot 2021-05-14 at 9.04.49 AM](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/b4bc43e1522d471c7dd1a9c1c49f61fbb739e82c.png)

---

<div class="post-metadata">

**Author:** ![trip\_humphrey](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@trip\_humphrey](https://discourse.getdbt.com/u/trip_humphrey)\
**Post date:** [May 22, 2021, 1:47am UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/2 "2021-05-22T01:47:19Z")

</div>

I just recently rolled out a dbt workstation environment to a team of 15 and I have been asked if this sort of configuration is possible using VSCode. The VSCode python extension behaves properly and locates the dbt virtualenv, but I ly by manually initiating the extension. Since it is only set to auto initialize on .py files…not .sql

Does anyone know if this is possible in VSCode?

---

<div class="post-metadata">

**Author:** ![robli](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/robli/32/316_2.png) [@robli](https://discourse.getdbt.com/u/robli)\
**Post date:** [May 22, 2021, 5:41am UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/3 "2021-05-22T05:41:47Z")

</div>

Re VS Code you might want to check this out to see if it suits your use case.

> **[dbt Power User - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=innoverio.vscode-dbt-power-user)**
>
> Extension for Visual Studio Code - This extension makes vscode seamlessly work with dbt

---

<div class="post-metadata">

**Author:** ![trip\_humphrey](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@trip\_humphrey](https://discourse.getdbt.com/u/trip_humphrey)\
**Post date:** [May 22, 2021, 1:38pm UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/4 "2021-05-22T13:38:54Z")

</div>

Thanks, I will take a look at it.

---

<div class="post-metadata">

**Author:** ![Nige](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/nige/32/669_2.png) [@Nige](https://discourse.getdbt.com/u/Nige)\
**Post date:** [June 11, 2021, 6:59pm UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/5 "2021-06-11T18:59:05Z")

</div>

> [@makotonium](#):
>
> on the “+” icon to add SQL (

I’ve just commented on the ticket you raised as it has been conflated with the [DataGrip ticket](https://youtrack.jetbrains.com/issue/DBE-12416) and flagged as a duplicate which it patently isn’t.

---

<div class="post-metadata">

**Author:** ![Kuntur](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@Kuntur](https://discourse.getdbt.com/u/Kuntur)\
**Post date:** [September 29, 2023, 1:12pm UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/6 "2023-09-29T13:12:53Z")

</div>

I was trying to follow your steps but whenever I setup jinja2 it affects my keyboard and i am not able to type anything anymore in my IDE (Pycharm pro), anyone experienced something similar ?

Thanks

---

<div class="post-metadata">

**Author:** ![StrangeRationality](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/strangerationality/32/3069_2.png) [@StrangeRationality](https://discourse.getdbt.com/u/StrangeRationality)\
**Post date:** [October 6, 2023, 10:49pm UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/7 "2023-10-06T22:49:40Z")

</div>

I am experiencing the same thing in PyCharm. I am able to set up the .sql files to have templates but when I specify the template language as Jinja, all my keyboard inputs are eaten up.

---

<div class="post-metadata">

**Author:** ![adi.levhar1](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@adi.levhar1](https://discourse.getdbt.com/u/adi.levhar1)\
**Post date:** [November 23, 2023, 10:30am UTC](https://discourse.getdbt.com/t/enabling-jinja-syntax-support-in-sql-files-in-pycharm/2536/8 "2023-11-23T10:30:07Z")

</div>

Same issue for me using PyCharm 2023.2.1 (Professional Edition).  
Does someone has a solution?
