Skip to main content
Data source class for populating select parameter options from a database table or query. This class can be imported from the squirrels.data_sources or the squirrels module.

Constructor

Creates a SelectDataSource object.

Examples

A SelectDataSource object is created in the pyconfigs/parameters.py file. It must be created in a function decorated with the create_from_source factory method from SingleSelectParameter or MultiSelectParameter.

Usage example in parameters.py

In addition, the following are some additional examples for creating a SelectDataSource object.

Using a table from a specific connection

This example uses a table called “departments” from the “hr_db” connection.
The connection must either be defined in squirrels.yml or the connections.py file.

Using seeds as the data source

This example uses a seed file called “status_codes”.

Setting default selected options

This example marks certain options as selected by default using a column that contains 1 or 0.

Adding custom fields to options

This example creates the following custom fields on each parameter option:
  • code (from column country_code)
  • population (from column population_count)
  • continent (from column continent_name)

Enabling cascading effects with a parent parameter

In this example, the available product options are filtered based on the selected value of another parameter called “product_category”.