execute dbt models from macro

The problem I’m having

to execute dbt model in loop via macro

The context of why I’m trying to do this

I have lookup table, where we keep track of countries. We need to execute the list of models, for all active countries depending on lookup table, execute these models in sequence.

What I’ve already tried

I created the macro that have array with model names.
and a for loop that will execute depending in lookup table’s count.

image

But to execute dbt model like dbt run -s modelname.sql, its not working.
can anyone help me with it

dbt compiles SQL code and sends it to the data platform to be run, it does not run terminal commands

If you use dbt cloud you can use the job scheduler

If you use dbt core you should use some kind of orchestrator like airflow