Skip to main content

MindsDB configurations

Authentication

To succesfully connect dbt to MinsDB you will need to provide the following configuration from the MindsDB instance.

KeyRequiredDescriptionSelf-hostedMindsDB Cloud
type✔️The specific adapter to usemindsdbmindsdb
host✔️The MindsDB (hostname) to connect toDefault to 172.0.0.1Default to cloud.mindsdb.com
port✔️The port to useDefault to 47335Default to 3306
schema✔️Specify the schema (database) to build models intoThe MindsDB integration nameThe MindsDB integration name
username✔️The username to use to connect to the serverDefault to mindsdbYour mindsdb cloud username
password✔️The password to use for authenticating to the serverNo password by defaultYour mindsdb cloud password

Usage

Create dbt project, choose mindsdb as the database and set up the connection. Verify your connection works dbt debug

dbt init <project_name>

To create a predictor, create a dbt model with a "predictor" materialization. The name of the model will be the name of predictor.

Parameters:

  • integration - name of used integration to get data from and save result to. Must be created in mindsdb beforehand using the CREATE DATABASE syntax.
  • predict - field for prediction
  • predict_alias [optional] - alias for predicted field
  • using [optional] - options for configure trained model
-- my_first_model.sql    
{{
config(
materialized='predictor',
integration='photorep',
predict='name',
predict_alias='name',
using={
'encoders.location.module': 'CategoricalAutoEncoder',
'encoders.rental_price.module': 'NumericEncoder'
}
)
}}
select * from stores

To apply predictor add dbt model with "table" materialization. It creates or replaces table in selected integration with results of predictor. Name of the model is used as name of the table to store prediction results. If you need to specify schema you can do it with dot separator: schema_name.table_name.sql

Parameters

  • predictor_name - name of the predictor. It has to be created in mindsdb.
  • integration - name of used integration to get data from and save result to. Must be created in mindsdb beforehand using the CREATE DATABASE syntax.
    {{ config(materialized='table', predictor_name='TEST_PREDICTOR_NAME', integration='photorep') }}
select a, bc from ddd where name > latest
0