How to use AI to automatically generate a Python script using dbt syntax

Use artificial intelligence to instantly generate a full Python script from a dbt model.

Published on Apr 30, 2024 by AirOps Team

dbt release 1.3 brought Python support to dbt.   🎉 

This is great news – SQL is powerful, but Python helps data practitioners unlock even more value from their data.

That said, most analysts find that Python is a much trickier language to learn. 

Fortunately, you don’t have to be fluent in Python to use it in your dbt workflows. Keep reading to learn how to use Data Sidekick, a free AI-assisted data tool from AirOps, to generate Python scripts from your dbt models.

Use artificial intelligence to instantly generate Python scripts from dbt data models

Data Sidekick contains a variety of recipes that automate common data-related tasks, including writing dbt SQL, generating YAML entries for dbt models, and generating Python scripts (using the correct structure and syntax) for use inside dbt. 

To generate a complete Python script that uses dbt syntax, Sidekick combines context from your data warehouse with the power of AI to generate a complete Python script that uses dbt syntax.

This is what the dbt Python Model Creator recipe looks like in action:

dbt Python Model Creator is just one of many recipes in Sidekick. You can also use it to:

  • Write SQL queries using plain English  🪄
  • Auto document table schemas ✍️
  • Optimize SQL queries to improve speed and trim your warehouse bill 💸

… and more (we’re always working on new recipes).

Sidekick is completely free for individual use. You don’t even need a credit card to sign up – jump in and give your Python powers an instant boost.

See how Data Sidekick’s dbt Python Model Creator recipe works in real life

Want to see how Sidekick performs in real life

Check out how Kyle Dempsey, Head of CX and Solutions Architecture at AirOps, uses Sidekick to supercharge his Python skills. ⬇

Before Sidekick, how long did it take you to write Python scripts for your dbt models?
I’m a SQL veteran, but writing, testing, and deploying Python scripts takes me a lot longer. I can do it, but I’m not super efficient.

If writing a SQL query takes me anywhere from 30 seconds to 30 minutes, creating a full Python script can take twice as long (or longer, depending on the complexity of the script).
How has Sidekick changed the way you work with Python?
Depending on what exactly I’m doing, Sidekick can save me hours of time researching, building, and testing Python scripts. When I use multiple recipes in my workflow, like the dbt Python Model Creator, dbt SQL Writer, and dbt SQL Config, I can be even faster and more efficient.