
Prerequisites
Before you begin, ensure you have the following prerequisites:- Python installation: You need Python 3.8 or higher installed on your machine. You can download it from python.org.
- Firebolt account: You need an active Firebolt account with a configured database and engine. If you don’t have one, you can sign up for free.
- Firebolt credentials: Create a service account in Firebolt and note its client ID and secret.
- LLM API key: You’ll need an API key from a supported LLM provider to power the natural language processing. This guide uses OpenAI as an example, but LangChain supports many other chat model providers. You can obtain an OpenAI API key from the OpenAI website.
Connecting to Firebolt with LangChain
1. Install Required Packages
Install the necessary Python packages. This example uses OpenAI, but you can install packages for any LangChain-supported chat model:2. Set Up Environment Variables
For security best practices, store your credentials as environment variables. This example uses OpenAI, but you can use any LangChain-supported model:3. Configure the Connection
Connect to Firebolt using a SQLAlchemy engine. You’ll need to provide your Firebolt credentials and the database connection details:client_id
: client ID of your service account.client_secret
: client secret of your service account.account_name
: The name of your Firebolt account.database
: The name of the database to connect to.engine
: The name of the engine to run SQL queries on.
Usage Examples
Basic Database Analysis
Natural Language Queries
Advanced Analytics
Compatibility and Limitations
- LangChain Versions: This integration is compatible with LangChain 0.1.0 and later versions.
- Performance: For large datasets, consider using appropriate filters and limits in your natural language prompts to optimize query performance.
- Token Limits: Be aware of LLM token limits when working with large schema descriptions or query results.
Further Reading
- Learn more about LangChain SQL agents and their capabilities
- Explore LangChain chat model integrations to see all supported LLM providers
- Review the Firebolt SQLAlchemy documentation for advanced connection options
- Visit LangChain’s documentation for more advanced use cases and integrations