HomePublicationsCertificationsCompetitionsContributors
Start publication
HomePublicationsCertificationsCompetitionsContributors

Table of contents

Code

Datasets

Files

AboutDocsPrivacyCopyrightContactSupport
Ā© Ready Tensor, Inc.
Back to publications
Feb 14, 2025ā—12 readsā—No License

Query Databases with AI

  • #agent
  • #generativeai
  • #langchain
  • #llm
  • c
    @chaubeyr.ravi

Table of contents

LangChain SQL Chatbot: Query Databases with AI

šŸš€ Interact with SQL databases using natural language! This open-source Streamlit app leverages LangChain and Groq Llama3 to enable conversational querying of SQLite, PostgreSQL, and MySQL databases.


Features

āœ… Chat with your database using AI
āœ… Supports SQLite, PostgreSQL, and MySQL
āœ… Uses LangChain SQL Agent for intelligent query generation
āœ… Secure API Key input for Groq Llama3 model
āœ… Optimized for performance with caching


Installation

1. Clone the Repository

git clone https://github.com/ravirch/Query-Databases-with-AI.git cd langchain-sql-chatbot

2. Create a Virtual Environment

python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Run the Streamlit App

streamlit run app.py

Configuration

Database Connection

  1. SQLite: Uses student.db by default.
  2. PostgreSQL: Enter host, user, password, and database name in the sidebar.
  3. MySQL: Similar setup to PostgreSQL.

API Key

You need a Groq API Key to use the Llama3 model. Enter it in the sidebar.


Usage

  1. Select a database from the sidebar.
  2. Provide credentials (if using PostgreSQL/MySQL).
  3. Enter your query in plain English (e.g., "Show top 10 students from student.db").
  4. The chatbot generates and executes the SQL query.
  5. View responses instantly in the chat interface.

Tech Stack

  • Streamlit → UI & Chatbot Interface
  • LangChain → SQL Agent for Query Processing
  • Groq Llama3 → AI-Powered Query Understanding
  • SQLAlchemy → Database Connection
  • SQLite, PostgreSQL, MySQL → Supported Databases

Table of contents

Your publication could be next!

Join us today and publish for free

Sign Up for free!

Table of contents

Code

  • Main

Code

  • Main

Datasets

  • Sqlite.py

Datasets

  • Sqlite.py