· Aug 21 6m read

IRIS Tables in dbt (Data Build Tool) with Python



A Quick start to include InterSystems IRIS Tables in Data Build Tool using Python.

It uses the sqlalchemy plugin with sqlalchemy-iris which enables the iris strategy for duckdb as a source for a dbt project.

EDIT: If you stumbled here on Google Geuse for "iris dbt", your best bet is to checkout dbt-iris for the native adapter implementation that follows dbt guidelines.

Im out of town for the Python meetup in Cambridge, but will submit to the InterSystems Python Programming Contest starting in September. Sucks I will miss it, wanted to connect with Thomas Dyer and see how close I got, but this is my virtual hail to the event through the community.

It is a quick start at best, for those perusing it, and even for myself to build upon in the upcoming months.


I am unsure this is solution is the best path to accomplish things, but it is a tested path.

I am not a dbt expert, but use dbt-core in cicd pipelines and its apparent in bash history on a daily basis, so I walk around like I eventually will be.


Made possible by SQLAlchemy-iris by Dmitry Maslennikov and a follow up post by Heloisa Paiva to express in a few lines how great it is.

Also, duckdb is fun software, wicked fast, and a data lake for your /tmp folder. Ducks are cool, Geese are not.


  • Deploy IRIS Cloud SQL
  • Pythons
  • Github
  • dbt Configuration
  • Validate Setup

So we used InterSystems IRIS Cloud SQL through the Early Access Program to demonstrate things, it provisioned super fast and anything to avoid local docker these days makes for a happy brogrammer.


Looks like I got a roll of 112 ones left on my trial.

For purposes of the tables referenced in the below, I used DBeaver to create a Table "Persons" in the "SQLUser" schema and loaded it up with a bunch of worthless data.



Install the following python stuff, I am running python3.8, and everything seems to work fine.

pip install dbt-core
pip install dbt-duckdb
pip install sqlalchemy-iris


Optional, but not really if you are serious about things.

dbt Configuration

Inside the git repository folder:

dbt init iris_project

Setup your profile, if you are familiar with .aws credentials for your system, this is similar, but for the secrets connecting to your sources.

In ~/.dbt/profiles.yml

Construct your sqlalchemy URI from you connectivity details in IRIS SQL, and populate it like so:


  target: dev
      type: duckdb
      database: dbt 
      schema: dev 
      path: /tmp/dbt.duckdb
        - module: sqlalchemy
          alias: sql
            connection_url: "iris://"

Modify the dbt_project.yml in the root of the dbt project.

name: 'iris_project'
version: '1.0.0'
config-version: 2

# This setting points to the "profile" we built from previous step.
profile: 'dbt_iris_profile'

model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

  - "target"
  - "dbt_packages"

      +materialized: view

  db_name: sql

Two more files to go, lets declare our models\schema.yml first:

version: 2

  - name: my_first_dbt_model
    description: "A starter dbt model"
      - name: id
        description: "The primary key for this table"
          - unique
          - not_null

  - name: my_second_dbt_model
    description: "A starter dbt model"
      - name: id
        description: "The primary key for this table"
          - unique
          - not_null

  - name: dbt_iris_source
    database: dbt
    schema: SQLUser 
      - name: Persons
        identifier: Persons
          plugin: sql
          save_mode: overwrite
          query: "SELECT * FROM SQLUser.Persons"

And last but not least, a Python model in models/

def model(dbt, session):

    persons_df = dbt.source("dbt_iris_source", "Persons")
    return persons_df

dbt Shampoo

Now let's test and see if we can reach IRIS out there in us-east-1 of sorts.

dbt debug

If all goes well, and we are able to connect to IRIS Sql Cloud, you should see something like the following:


Next up, is to actually run the project.

dbt run


Lets generate the clown suit and take a look at our work.

dbt generate docs
dbt serve docs

On, you'll see the auto generated docs.



Need some proof we connected to IRIS Sql Cloud and pulled down the Persons data?

Fire up the duckdb cli and query the dev.Persons table.


I am currently down with dbt (yeah you know me) using dbt-core to about 25% of its full potential and pretty much all in and most likely headed to dbt cloud. After a project that implemented Single Table DynamoDB, with a transform to BigQuery, it became apparent that there MUST be a better way to:

  • Share the project
    Github was not enough, there needed to be more ways to share the tribal knowledge and just not show up that day for somebody else to check it out and run. dbt shines here with dbt shampoo, dbt run && dbt test in pipelines.

  • Changes and Tribal Knowledge
    Source control gave us the code lineage, but dbt kept the tribal knowledge right there along side of it, so changes and additions could be made without fear of breaking things.

  • Testing
    My experience with some data projects is they get handled with the testing rigor of teams that build web apps and it is not a fit. Though the target data powers the UI (where the testing occurred), it only surfaced a fraction of the data complexity and raised a ton of bugs from the datawarehouse side of the project.

Very Helpful Stuff:

Ron Sweeney, Integration Required/PID^TOO||

Discussion (3)2
Log in or sign up to continue

Thats really good work, even follows the adapter guidelines.  Pointing the community your way before preceding down the post.

Looks like my process for pre-post searches to look for duplicate content needs a re-think:

These were goose eggs, so I proceeded down the path... however glad I played with duckdb and the plugins anyway.