You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Always start by defined the pyoso client with the OSO_API_KEY
9
+
10
+
```python
11
+
from pyoso import Client
12
+
import os
13
+
client = Client(os.getenv("OSO_API_KEY")) # never hard-code keys
14
+
```
15
+
16
+
---
17
+
18
+
#### 1. Generate SQL
19
+
20
+
Call the `generate_sql` MCP tool and pass in the user's NL query. This will return the proper SQL to use going forward.
21
+
22
+
Don't ever call the MCP tool in python code, just use it yourself to gather the proper SQL query. Only the end result SQl query should be written into the code.
23
+
24
+
```python
25
+
sql_query = 'output of generate_sql MCP tool'
26
+
```
27
+
28
+
---
29
+
30
+
#### 2. Run the SQL query across the DB
31
+
32
+
Pass in the sql_query gathered above into thepyoso client defined above with .to_pandas(), which should return a dataframe result of the query across pyoso's data lake.
33
+
34
+
```python
35
+
df = client.to_pandas(sql_query)
36
+
```
37
+
38
+
---
39
+
40
+
#### 3. (Optional) Analysis
41
+
42
+
Now, based on the user's request, you are free to continue working with the final dataframe and run any additional analysis they might want done on it.
0 commit comments