dbt-core-interface

raw JSON →
1.1.7 verified Mon Apr 27 auth: no python

A Python library providing an interface for interacting with dbt Core programmatically. It abstracts invocation, artifact parsing, and project management. Current version: 1.1.7, requires Python >=3.10 and <3.14. Active development with frequent releases.

pip install dbt-core-interface
error ModuleNotFoundError: No module named 'dbt_core_interface'
cause Package not installed or installed in a different Python environment.
fix
Run pip install dbt-core-interface in the correct environment (e.g., the virtual environment you're using).
error AttributeError: 'DbtCoreInterface' object has no attribute 'invoke_dbt'
cause The `invoke_dbt` method was removed in v1.1.0.
fix
Use the dedicated methods like run(), compile(), test() instead.
error dbt.exceptions.RuntimeException: Runtime Error Encountered an error: Can't determine which profile to use.
cause Multiple dbt profiles found or profiles_dir not set correctly.
fix
Explicitly set profiles_dir in the constructor: DbtCoreInterface(profiles_dir='/path/to/profiles').
error TypeError: DbtCoreInterface.__init__() got an unexpected keyword argument 'capture_output'
cause The `capture_output` parameter was added in v1.1.0. Using it with an older version raises this error.
fix
Upgrade to v1.1.0 or later: pip install --upgrade dbt-core-interface.
breaking The API changed significantly between v1.0.x and v1.1.x. The old `DbtCoreInterface` constructor required explicit project and profile paths; now these are optional and auto-detected.
fix Update calls to `DbtCoreInterface(project_dir='/path', profiles_dir='/path')` to accept the new defaults or remove explicit paths if they match the working directory.
deprecated The `invoke_dbt` method is deprecated in v1.1.0+. Use `run`, `compile`, `test`, etc. instead.
fix Replace `dbt.invoke_dbt(['run', '--select', 'my_model'])` with `dbt.run(select='my_model')`.
gotcha Running dbt inside a subprocess may produce unexpected log outputs. The library captures stdout/stderr but does not forward them in real-time by default.
fix Set `capture_output=False` in the DbtCoreInterface constructor to see live logs.
gotcha The library requires dbt-core to be installed in the same Python environment. If multiple dbt adapters are needed, they must be installed separately.
fix Ensure dbt-core and any required dbt adapters (e.g., dbt-postgres, dbt-snowflake) are installed alongside dbt-core-interface.

Initialize the interface and run a dbt model.

import os
from dbt_core_interface import DbtCoreInterface

dbt = DbtCoreInterface()
result = dbt.run(select='my_model')
print(result.success, result.logs)