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 enginedatabricks– use the built-in Databricks engineA dotted import path (e.g.
mypackage.backends.CustomEngine) – dynamically imported and instantiated with no arguments
Required.
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 |
|
Warehouse name (optional) |
|
Role name (optional) |
|
Schema name (optional) |
Variable |
Description |
|---|---|
|
Workspace hostname |
|
SQL warehouse HTTP path |
|
Personal access token |
|
Unity Catalog name (optional) |
|
Schema name (optional) |
Set SEMOLINA_ENV_FILE to load variables from a .env file instead of
the shell environment.
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