PyCharm 2024.3 Help

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 are not available, make sure that you did not disable the plugin.

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

  2. 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.

Select dbt configuration

You can create your own dbt configuration.

  1. Do one of the following:

    • Go to Run | Edit Configurations.

    • In the main toolbar, select Edit Configurations from the list of run/debug configurations.

  2. Press Alt+Insert or click Add New Configuration.

  3. Select dbt.

    Select dbt from the list
  4. Specify the configuration name and select command from the dbt command list.

    dbt configuration settings
  5. Specify additional arguments.

  6. Select Module.

  7. Set environment variables, if necessary. For example, you might use environment variables to manage different database connections for development, testing, and production environments.

  8. If you want to execute any task before the dbt command, click Add in the Before launch field and select a task.

  9. 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:

  1. Open an SQL file with your model.

  2. Click Run with dbt icon in the gutter. The list of the Gutter icons appears.

    dbt Gutter icons
  3. Select the icon to run a dbt command.

Gutter icon

dbt command

Run model Run model

dbt run --select model.sql

Test model Test model

dbt test --select model.sql

Preview model 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:

  1. Start working with your dbt project: preview, debug or run model.

  2. Open an SQL file with the model.

  3. Right-click inside the opened file and select Lineage from the context menu to view the DAG.

Last modified: 30 April 2024