Skip to content

abdul3asith/langgraph-sql-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

LangGraph SQL Agent πŸš€

A natural-language-to-SQL agent built with LangGraph and Mistral Medium 3 (watsonx.ai), allowing users to query a SQL database using plain English.
The agent generates, validates, and executes SQL queries (or optional Python queries) and returns formatted results β€” making data exploration conversational and intuitive.

🧠 Features

  • Translate natural language questions into safe, syntactically correct SQL queries.
  • Dynamically inspect database schema and list available tables.
  • Validate and double-check generated SQL before execution to avoid harmful or malformed queries.
  • Support for SELECT queries only (read-only): no INSERT / UPDATE / DELETE / DROP β€” ensuring safety for production-style usage.
  • Optionally execute Python code (via a REPL tool) for post-processing or custom analysis.
  • Return results in human-friendly format (e.g. tabular output), ideal for analytics or quick data insights.

πŸ› οΈ Tech Stack

  • Python β€” orchestration and agent logic
  • LangGraph (on top of LangChain) β€” to build the agent graph (planning, tool-calling, reasoning) :contentReference[oaicite:3]{index=3}
  • watsonx.ai Runtime + Mistral Medium 3 β€” for LLM-based natural-language β†’ SQL translation :contentReference[oaicite:4]{index=4}
  • SQLite (or any SQL database) β€” for storing and querying structured data :contentReference[oaicite:5]{index=5}
  • SQL (SQLite dialect) β€” query language
  • SQLDatabaseToolkit & related tools β€” for listing tables, generating schema introspection, executing queries, and validation :contentReference[oaicite:6]{index=6}

πŸ“¦ Getting Started

Prerequisites

  • Python 3.9+
  • A watsonx.ai account + runtime instance & API key (project ID) :contentReference[oaicite:7]{index=7}

Installation

pip install \
  ibm-watsonx-ai \
  langchain-ibm \
  langgraph \
  langchain-community \
  sqlalchemy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors