dbt support
PyCharm supports dbt® Core — an open-source data modeling tool that allows users to transform, test, and deploy data in their data warehouses using SQL.
Enable the dbt plugin
This functionality relies on the dbt plugin, which is bundled and enabled in PyCharm by default. If the relevant features aren't available, make sure that you didn't disable the plugin.
Press Ctrl+Alt+S to open settings and then select
.Open the Installed tab, find the dbt plugin, and select the checkbox next to the plugin name.
dbt support in PyCharm includes:
Effortless project creation: you can create your dbt® project using a predefined template.
Easy run, build, and debug: execute, build, or debug your project with Run/debug configurations in just a few clicks.
Quick access to dbt actions: run, test and preview models directly from an SQL file using the Gutter icons.
Intelligent code completion: PyCharm offers smart code completion for SQL and YML files.
Get familiar with the user interface
Run/debug configurations
To run a dbt command, select the dbt configuration from the list of run/debug configurations in the main toolbar and click Run.
You can create your own dbt configuration.
Do one of the following:
Go to
.In the main toolbar, select Edit Configurations from the list of run/debug configurations.
Press Alt+Insert or click Add New Configuration.
Select dbt.
Specify the configuration name and select command from the dbt command list.
Specify additional arguments.
Select Module.
Set environment variables, if necessary. For example, you might use environment variables to manage different database connections for development, testing, and production environments.
If you want to execute any task before the dbt command, click Add in the Before launch field and select a task.
Click OK to save the configuration.
Gutter icons
Gutter icons are located in the editor on the left. You can use them to execute dbt commands:
Open an SQL file with your model.
Click Run with dbt icon in the gutter. The list of the Gutter icons appears.
Select the icon to run a dbt command.
Gutter icon | dbt command |
---|---|
Run model | dbt run --select model.sql |
Test model | dbt test --select model.sql |
Preview model | dbt show --select model.sql |
DAG
Directed Acyclic Graph or DAG is a type of graph where the nodes have directional connections amongst themselves and don’t form a directional closed loop.
DAGs are highly useful if you want to understand the relationships within your data models and identify possible areas of improvement in your data transformation process.
You can open and view DAG for your models in PyCharm:
Start working with your dbt project: preview, debug or run model.
Open an SQL file with the model.
Right-click inside the opened file and select Lineage from the context menu to view the DAG.