Please rotate your device

To continue exploring this website, please rotate your device to a vertical orientation

Changelog

Access Queries in Worklets

Date

You’re now able to access queries from a code block in a Worklet! These queries can be in the form of raw SQL (as a string) or a name of a query you’ve defined earlier.

Access queries from a code block in a Worklet
Access queries from a code block in a Worklet

For example:

sql
new_query_output = context.run_query_str("select * from test_table") # to run raw SQL queries
existing_query_output = context.run_query_name("testquery") # to run a specific query you’ve already defined

These examples show queries against Baseten Postgres data tables. If you’d like to query external data sources you have connected to your Baseten account, check out our documentation.

To access the results of your queries, either return or print their output (new_query_output, existing_query_output) from your code block!