ModelArgs is the class type of the sqrl argument for the main function of “federate models” (i.e. data models in the models/federates/ folder), which runs when an API request is made to a dataset that uses the federate model.
The class can be imported from the squirrels.arguments or squirrels module.
Properties
Path to the Squirrels project directory.
A copy of project variables as a dictionary.
A copy of environment variables as a dictionary.
The current authenticated user.
A copy of the parameters dictionary.
A copy of the configurables dictionary.
A copy of the connections dictionary.
The set of dependent data model names.
A copy of the context variables dictionary.
Methods
set_placeholder()
Sets a placeholder value for use in SQL queries.An empty string (because this function is also available to call from Jinja).
param_exists()
Checks whether a given parameter exists and contains options.True if the parameter exists and is enabled, False otherwise.
ref()
Returns the result of a dependent model as a polars LazyFrame.A polars LazyFrame of the dependent model’s result.
run_external_sql()
Runs a SQL query against an external database.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.A polars DataFrame of the query result.
is_placeholder()
Checks whether a name is a valid placeholder.True if the name is a valid placeholder, False otherwise.
get_placeholder_value()
Gets the value of a placeholder. Use with caution to avoid SQL injection.The value of the placeholder or None if the placeholder does not exist.