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.
- To get started, open the app and hit
command
/ctrl
+k
→ "python" - [Optional] Add a
dict
namedseekwell
to the end of your script with the DataFrame's you want to return. This will make them available using SQL. - [Optional] Set your schedule
If your script returns DataFrames, you can access them with SQL by changing the Source to "Block"
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.
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.
Injecting a SQL result / using Parameters
You can add the result of an existing SQL block to your Python script using df
) and select the SQL block you want to use.
You can now reference df
in your Python code
df['added_with_python'] = 'yes'
seekwell = {'df': df}
When you run this, you'll see the results of your existing block appear along with your new added_with_python
column.