Step 1: Install dependencies
To work with DBT we must first install the Trino libraries:
pip install dbt-trino
Step 2: Create a project
Let’s init a DBT project:
dbt init
Give the project a meaningful name and select the trino database:
![](https://cdn.prod.website-files.com/66098d655e9084457b00d675/665f0c23c6a031e1618ac9c0_AD_4nXfKAdkQrm-3_oa7313CRQvNbCpHMJU_InWZO-f6g9DHUa8MVMnkujjD2mSYn5TYnda6qAMKqMaHJQLLnUwSzxtUA_tYNL4NZ5J1-tKU7ZoA4AUxmKBtPdhXmFwj2WH2j71iqA3p9mP1aKSvVYAMnuCxFzQ.png)
Step 3: Configure the database connection
In the newly created project directory create a new file named “profiles.yml”. This should contain the following:
<project name>:
target: dev
outputs:
dev:
type: trino
method: none
user: admin
database: kafka
host: streambased.cloud
port: 8443
schema: streambased
threads: 1
http_scheme: https
![](https://cdn.prod.website-files.com/66098d655e9084457b00d675/665f0c51a9a6cd1c3ce6af6a_AD_4nXdKLmliAlnM-uww7GwO31Z4IcozXUbU1IzS9ETlxgVBk9IBb_M4EeEE5wNM10Pk2RF-cJhKSA0Vv_A921XloMr49NKSwo4gWNFr07G3fKGezKk1xBPW2n9RaEt0-VV-RgxCTbShLCUQLtIcmT0jvOCv8rdu.png)
Step 4: Create a model
In the “models” directory create a new file with the extension “.sql” (in this example transactions.sql). This should contain the SQL you wish to run:
SELECT * FROM kafka.streambased.demo_transactions
Step 5: Run the query
We can test run the query directly with DBT:
dbt show --select models/transactions.sql
![](https://cdn.prod.website-files.com/66098d655e9084457b00d675/665f0c8a80903604d09b221f_AD_4nXf8g7iAz1ZE-7gh3RRaHOZBnShIpa0DlH9xw2Mu01ZjGCM8todGsNUBRlZ7b5tsCfoFdzLvmBCgtijoKfHaPgMznGlzO4AxATqIt7HY0v-syOVJnvZMyuoGhYieTTK7nEGHUBG8OlKDP1deNEAClukfLlez.png)