Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.pysquirrels.com/llms.txt

Use this file to discover all available pages before exploring further.

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

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.
user
AbstractUser
The current authenticated user.
prms
dict[str, Parameter]
A copy of the parameters dictionary.
configurables
dict[str, str]
A copy of the configurables dictionary.
connections
dict[str, Any]
A copy of the connections dictionary.
dependencies
set[str]
The set of dependent data model names.
ctx
dict[str, Any]
A copy of the context variables dictionary.

Methods

set_placeholder()

Sets a placeholder value for use in SQL queries.
def set_placeholder(self, placeholder: str, value: TextValue | Any) -> str:
returns
str
An empty string (because this function is also available to call from Jinja).

param_exists()

Checks whether a given parameter exists and contains options.
def param_exists(self, param_name: str) -> bool:
returns
bool
True if the parameter exists and is enabled, False otherwise.

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, **kwargs
) -> 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, 
    **kwargs
) -> polars.DataFrame:
returns
polars.DataFrame
A polars DataFrame of the query result.

is_placeholder()

Checks whether a name is a valid placeholder.
def is_placeholder(self, placeholder: str) -> bool:
returns
bool
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.
def get_placeholder_value(self, placeholder: str) -> Any | None:
returns
Any | None
The value of the placeholder or None if the placeholder does not exist.