forked from Sinaptik-AI/pandas-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
from_snowflake.py
35 lines (28 loc) · 1.18 KB
/
from_snowflake.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Example of using PandasAI with a Snowflake"""
import os
from pandasai import Agent
# The usage of this connector in production is subject to a license ([check it out](https://github.com/Sinaptik-AI/pandas-ai/blob/master/pandasai/ee/LICENSE)).
# If you plan to use it in production, [contact us](https://forms.gle/JEUqkwuTqFZjhP7h8).
from pandasai.ee.connectors import SnowFlakeConnector
snowflake_connector = SnowFlakeConnector(
config={
"account": "ehxzojy-ue47135",
"database": "SNOWFLAKE_SAMPLE_DATA",
"username": "test",
"password": "*****",
"table": "lineitem",
"warehouse": "COMPUTE_WH",
"dbSchema": "tpch_sf1",
"where": [
# this is optional and filters the data to
# reduce the size of the dataframe
["l_quantity", ">", "49"]
],
}
)
# By default, unless you choose a different LLM, it will use BambooLLM.
# You can get your free API key signing up at https://pandabi.ai (you can also configure it in your .env file)
os.environ["PANDASAI_API_KEY"] = "your-api-key"
agent = Agent(snowflake_connector)
response = agent.chat("How many records has status 'F'?")
print(response)