Connect dbt to a MariaDB warehouse, run models, and manage incremental transformations through the dbt-mariadb adapter.
dbt lets engineers version SQL, test data, and build incremental pipelines. Pairing it with MariaDB keeps storage costs low while adding software-engineering workflows.
Run pip install dbt-mariadb
. The package supplies a profile template, macro implementations, and a MariaDB-aware materialization layer.
profiles.yml
for MariaDB?Create ~/.dbt/profiles.yml
with a mariadb
type. Provide host, port, user, and schema. Use environment variables for secrets.
galaxy
_maria:
target: dev
outputs:
dev:
type: mariadb
server: localhost
user: $DB_USER
password: $DB_PASS
port: 3306
database: galaxy
schema: analytics
dbt debug
validates connectivity. dbt run
builds models. dbt test
executes tests. dbt build
combines run, test, and docs.
Place SQL in models/
. Reference sources via {{ source("public", "orders") }}
. Materialize as views, tables, or incremental tables.
-- models/revenue_by_customer.sql
select c.id, c.name,
sum(o.total_amount) as lifetime_spend
from {{ source("public", "customers") }} c
join {{ ref("stg_orders") }} o on o.customer_id = c.id
where o.order_date >= '2023-01-01'
group by 1,2
Add {{ config(materialized='incremental', unique_key='id') }}
then filter is_incremental()
rows. dbt will append only new records.
{{ config(materialized='incremental', unique_key='id') }}
select *
from {{ source('public','orders') }}
{% if is_incremental() %}
where order_date > (select max(order_date) from {{ this }})
{% endif %}
Use cron
, Airflow, or GitHub Actions to call dbt run --profiles-dir ~/.dbt --project-dir .
. Store connection secrets in CI vaults.
1) Partition fact tables by date to speed incremental merges. 2) Enable multi_statements
for faster builds. 3) Use dbt deps
to pin package versions.
Without a unique key dbt performs full overwrites. Always define unique_key
in the model config.
MariaDB treats keywords strictly. Quote identifiers or rename columns to avoid parse errors.
Yes. Place CSVs in the seeds
folder and run dbt seed
. dbt will create tables in the target schema.
dbt can run run-operation
macros that execute DDL, including stored procedures, but models themselves should remain declarative SQL.
MariaDB on Linux is case-sensitive. Use lower_case_table_names=1 or quote identifiers consistently to avoid schema mismatches.