Python [deprecated, desupported]

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 begin, open the app and hit command / control + k, and entering "python".

  2. [Optional] Add a dict named seekwell to the end of your script with the DataFrames you want to return. This will make them available using SQL.

  3. [Optional] Set your schedule.

    Schedule your SQL

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

Change source to Sheets/CSV/Block

Example

Create a new block named "SuperBowl" and add the script below. Hit command / control + k, enter "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}

The results appear in the app. Next, 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.

Select SuperBowl block

Run the query and SQL sums the Wins. You can now send the results to any destination (e.g. Google Sheets) as you normally would.

Sum of SuperBowl wins

Injecting a SQL result / using Parameters

You can add the result of an existing SQL block to your Python script using ⚙ Parameters. First select "Add parameter" in the right sidebar and choose "Block" as the type. Name the parameter (e.g. df) and select the SQL block you want to use.

Add parameter
Select Block for parameter

You can now reference df in your Python code:

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

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

SeekWell is not meant for ad-hoc Python analysis and thus is not intended to debug your script. Be sure to test your scripts locally or in another cloud environment like Colab before scheduling the script on SeekWell.