Create and materialize assets
In the first step of the tutorial, you created your Dagster project with the raw data files. In this step, you will:
- Create your initial Definitions object
- Add a DuckDB resource
- Build software-defined assets
- Materialize your assets
1. Create a definitions object
In Dagster, the Definitions
object is where you define and organize various components within your project, such as assets and resources.
Open the definitions.py
file in the etl_tutorial
directory and copy the following code into it:
import json
import os
from dagster_duckdb import DuckDBResource
import dagster as dg
defs = dg.Definitions(
assets=[],
resources={},
)
2. Define the DuckDB resource
In Dagster, Resources are the external services, tools, and storage backends you need to do your job. For the storage backend in this project, we'll use DuckDB, a fast, in-process SQL database that runs inside your application. We'll define it once in the definitions object, making it available to all assets and objects that need it.
defs = dg.Definitions(
assets=[],
resources={"duckdb": DuckDBResource(database="data/mydb.duckdb")},
)