fetch_vectors_to_database
Fetch multiple Statistics Canada vector IDs in a single call and store results into a SQLite table, eliminating separate insert steps. Ideal for multi-series analysis like provincial breakdowns.
Instructions
PREFERRED tool for multi-series analysis. Fetches data for multiple StatCan vector IDs in a single API call and immediately stores the results in a SQLite table — no separate create/insert steps needed.
*** USE THIS TOOL whenever you need data for multiple provinces, age groups, industries, or any other breakdown. It replaces the slow pattern of calling get_data_from_cube_pid_coord_and_latest_n_periods once per series. ***
Typical workflow:
search_cubes_by_title("unemployment rate") → find productId
get_cube_metadata(productId=...) → find vectorIds for each series you want
fetch_vectors_to_database( vectorIds=["v111","v222","v333"], table_name="unemployment_by_province", startRefPeriod="2023-01-01", endRefPeriod="2024-12-31" ) ← single call fetches + stores everything
query_database("SELECT * FROM unemployment_by_province") → analyze
Args: input_data.vectorIds: List of vector IDs to fetch (strings, e.g. ["111","222"]). input_data.table_name: SQLite table to create and populate. input_data.startRefPeriod: Optional start date (YYYY-MM-DD). input_data.endRefPeriod: Optional end date (YYYY-MM-DD).
Returns: Dict with table name, columns, rows_inserted, and a 5-row sample so you can verify the data looks right before querying.
IMPORTANT: In your final response cite the vectorIds and reference period used.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vectorIds | Yes | List of StatCan vector IDs to fetch (e.g. ['111', '222', '333']). Get these from get_cube_metadata → dimension members → vectorId field. | |
| table_name | Yes | Name of the SQLite table to create and populate. Use snake_case, e.g. 'unemployment_by_province'. | |
| sample_size | No | Number of sample rows to include in the response preview. Default 5. | |
| endRefPeriod | No | End of the reference period to fetch, inclusive. Format: YYYY-MM-DD. | |
| startRefPeriod | No | Start of the reference period to fetch, inclusive. Format: YYYY-MM-DD. |