🐍

Python

You can schedule Python scripts to run on a schedule or use them to return DataFrame's which can then be queried by you or your team with SQL.

  1. To get started, open the app and hit command / ctrl + k → "Python"
  2. [Optional] Add a dict named seekwell to the end of your script with the DataFrame's you want to return. This will make them available using SQL.
  3. [Optional] Set your schedule
  4. image

If your script returns DataFrames, you can access them with SQL by changing the Source to "Block"

image

Example

Create a new block named "SuperBowl" and add the script below. Hit command / ctrl + k → "Python" and run the block.

import pandas as pd
dfs = pd.read_html('https://en.wikipedia.org/wiki/Super_Bowl')
df = dfs[2]
df
seekwell = {'winRates': df}

You'll see the results show up in the app. Now create a new block, change the Source to "Block" and paste in the query below:

select sum("Wins") as total_wins
from {{SuperBowl}}

In the Parameters section, change the type to Block, select "SuperBowl" as the block and "winRates" as the DataFrame.

image

Run the query and you'll see the Wins summed using SQL! You can now send the results to any destination (e.g. Google Sheets) as you normally would.

image

Injecting a SQL result / using Parameters

You can add the result of an existing SQL block to your Python script using

. For example, using this code:

df = {{df}}
df['added_with_python'] = 'yes'
seekwell = {'df': df}

You'll see a "Parameters" section appear on the right. Select the "Block" as the type and select the block you want to "inject" from the drop down

image

When you run this, you'll see the results of your existing block appear along with your new added_with_python column.

💡

SeekWell is not meant for adhoc Python analysis and thus is not a great place to debug your script. Be sure to test your scripts locally or in another cloud environment like Colab before scheduling the script on SeekWell.