Skip to main content

Llamhub SnowflakeReader: A Loader to query and chat Snowflake Data in your LLM Applications

 

Snowflake Loader for LLM

Recently my second contribution to Llamaindex "SnowflakeReader" was merged to Lllamahub repository. This loader connects to Snowflake (using SQLAlchemy under the hood). The user specifies a query and extracts Document objects corresponding to the results. This loader is designed to be used as a way to load data into LlamaIndex and/or subsequently used as a Tool in a LangChain Agent. 




Usage

Option 1: Pass your own SQLAlchemy Engine object of the database connection

Here's an example usage of the SnowflakeReader.

from llama_index import download_loader SnowflakeReader = download_loader('SnowflakeReader') reader = SnowflakeReader( engine= your_sqlalchemy_engine, ) query = "SELECT * FROM your_table" documents = reader.load_data(query=query)

Option 2: Pass the required parameters to esstablish Snowflake connection

Here's an example usage of the SnowflakeReader.

from llama_index import download_loader SnowflakeReader = download_loader('SnowflakeReader') reader = SnowflakeReader( account='your_account', user='your_user', password='your_password', database='your_database', schema='your_schema', warehouse='your_warehouse', role='your_role', # Optional role setting proxy='http://proxusername:proxypassword@myproxy:port' # Optional proxy setting ) query = "SELECT * FROM your_table" documents = reader.load_data(query=query)

Langchain compatibility

documents = [ doc.to_langhchain_format() for doc in documents ]


Semantic Kernel compatibility


Convert documents to MemoryRecord objects

documents = [ doc.to_semantic_kernel_format() for doc in documents ]








Author

Godwin Paul Vincent


Comments

Popular posts from this blog

FTP C# Error : “The remote server returned an error: (530) Not logged in ."

  Recently working on a FTP solution using C# , i encountered an error  “ The  remote server returned an error: (530) Not logged in.” The code i used was following: FtpWebRequest request = (FtpWebRequest)WebRequest.Create( ftp://xxxxxx/file.txt ); request.Method = WebRequestMethods.Ftp.UploadFile request.Credentials = new NetworkCredential(usernameVariable, passwordVariable); What was more bewildering was if i modified the code to following, the solution was working fine. But this for obvious reasons is not an option as the username cannot be hardcoded //works but implausible to use in realtime solutions request.Credentials = new NetworkCredential("dmn/#gsgs", password);  Some googling revealed that special charcters create issues in the NetworkCredential Object. Hence some playing around worked for me, and it works irrespective of wether i do a FTPWebRequest or WebRequest. Solution: Instantiate NetworkCredential object with three paramters (username, pass...

How to Integrate Anaconda Prompt and Jupyter Notebook with CMDER

I personally find CMDER a fantastic tool and do believe its the best windows console emulator out there. I prefer make use of its  capability  to run multiple commands side by side with split panes and tabs, which helps multitasking and productivity. For those of you who aren't aware,  CMDER  is a user-friendly console emulator for Windows that offers numerous features, including a sleek and intuitive GUI, making it easy for users, including beginners, to interact with the command line.   In this blog, I'll guide you through the steps to set up CMDER to work similar to Anaconda Prompt, a popular environment for Python development.  A Step-by-Step Guide to Anaconda Prompt Integration in CMDER     Step 1: Navigate to Anaconda Prompt Before we begin, ensure you have Anaconda installed on your system. Open the Anaconda Prompt to find the location of the 'conda' executable. Step 2: Locate the 'conda' Executable In the Anaconda Prompt, enter the followi...