Execute DBT from Python using dbtRunner


I’d like to execute dbt run from Jupyter notebook using: from dbt.cli.main import dbtRunner, dbtRunnerResult. I use dbt 1.5.1 and python 3.10.11

I have 2 project variables that I want to control: v_country and v_report_date.
I am using following python command:

from dbt.cli.main import dbtRunner, dbtRunnerResult
run_list=["run"]+["--vars"]+["v_country: " + str('sk')]+["--vars"]+['v_report_date: "'+str('2023-06-30')+'"']
# initialize
dbt = dbtRunner()
# run the command
res: dbtRunnerResult = dbt.invoke(run_list)

dbt runs successully but for some reason in the models in changes only v_report_date variable, not the v_country. Instead it uses value of v_country defined in dbt_project.yml.

I tried to run it using just one --vars and it worked fine, so I think the problem is how to use both of them together…

Can you help me to modify the python command to change values of both variables?

Thank you