Skip to main content
BuildModelArgs is the class type of the sqrl argument for the main function of “build models” (i.e. data models in the models/builds/ folder), which runs at build time. The class can be imported from the squirrels.arguments or squirrels module.

Properties

project_path
str
Path to the Squirrels project directory.
proj_vars
dict[str, Any]
A copy of project variables as a dictionary.
env_vars
dict[str, str]
A copy of environment variables as a dictionary.
connections
dict[str, Any]
A copy of the connections dictionary which maps connection keys to SQLAlchemy Engines or other objects.
dependencies
set[str]
The set of dependent data model names.

Methods

ref()

Returns the result of a dependent model as a polars LazyFrame.
def ref(self, model: str) -> polars.LazyFrame:
returns
polars.LazyFrame
A polars LazyFrame of the dependent model’s result.

run_external_sql()

Runs a SQL query against an external database.
def run_external_sql(
    self, connection_name: str, sql_query: str
) -> polars.DataFrame:
returns
polars.DataFrame
A polars DataFrame of the query result.

run_sql_on_dataframes()

Uses a dictionary of dataframes to execute a SQL query in an embedded DuckDB database.
def run_sql_on_dataframes(
    self, sql_query: str, *, dataframes: dict[str, polars.LazyFrame] | None = None
) -> polars.DataFrame:
returns
polars.DataFrame
A polars DataFrame of the query result