CLI reference¶
The semolina command-line tool provides warehouse introspection and code
generation utilities. It is installed as a console script with the
semolina package.
$ semolina [OPTIONS] COMMAND [ARGS]...
Global options¶
--versionPrint the installed version and exit.
--helpShow the help message and exit.
semolina codegen¶
Introspect warehouse semantic views and generate
SemanticView model classes as Python source code.
$ semolina codegen [OPTIONS] VIEWS...
Arguments¶
VIEWSOne or more schema-qualified view names to introspect (e.g.
my_schema.sales_view). Required.
Options¶
--backend,-bTEXTBackend to connect to. Accepts one of:
snowflake– use the built-in Snowflake backenddatabricks– use the built-in Databricks backendduckdb– use the built-in DuckDB backendA dotted import path (e.g.
mypackage.backends.CustomEngine) – dynamically imported and instantiated with no arguments
Required.
--database,-dTEXTPath to a DuckDB database file. Only used with
--backend duckdb. Falls back toDUCKDB_DATABASEenvironment variable if not provided.
Exit codes¶
Code |
Meaning |
|---|---|
0 |
Success |
1 |
Unexpected error |
2 |
Invalid |
3 |
View not found in the warehouse |
4 |
Connection or authentication failure |
Environment variables¶
codegen reads credentials from environment variables. The required
variables depend on the backend.
Variable |
Description |
|---|---|
|
Account identifier (e.g. |
|
Username |
|
Password |
|
Database name (optional; needed to resolve unqualified view names) |
|
Warehouse name (optional; needed to run queries) |
|
Role name (optional) |
|
Schema name (optional) |
Variable |
Description |
|---|---|
|
Workspace hostname |
|
SQL warehouse HTTP path |
|
Personal access token |
|
Unity Catalog name (optional) |
|
Schema name (optional) |
Variable |
Description |
|---|---|
|
Path to DuckDB database file (fallback for |
Set SEMOLINA_ENV_FILE to load variables from a .env file instead of
the shell environment. DuckDB does not use .env files – pass the
database path with --database or DUCKDB_DATABASE.
See How to configure codegen credentials for the full credential loading chain,
.env file setup, and TOML config fallback.
Output¶
Generated Python source is written to stdout. Diagnostic messages (errors, warnings) go to stderr. Redirect stdout to write a file:
$ semolina codegen my_schema.sales_view -b snowflake > models.py
The output contains one SemanticView subclass per
introspected view, with typed Metric,
Dimension, and Fact fields.
See also¶
How to generate Semolina model classes from warehouse views – how to generate models from your warehouse
How to configure codegen credentials – credential configuration for codegen
How to define models – understanding the generated model classes