# langchain_data_agent — NL2SQL Data Agent CLI > NL2SQL data agent with a CLI (`data-agent`) built on LangGraph/LangChain. Ask questions in English to get SQL + results, with per-source configs. ## Install Copy the content below into your project: ## Quick Use ```bash git clone https://github.com/eosho/langchain_data_agent cd langchain_data_agent uv sync --all-extras cp .env.example .env data-agent --help ``` ## Intro langchain_data_agent turns natural-language questions into SQL with a CLI front-end, routing queries to specialized agents per config—useful for repeatable data Q&A workflows. **Best for:** Data teams prototyping NL2SQL assistants with repeatable configs and CLI workflows **Works with:** Python 3.12+ + uv; uses `.env` for credentials (per README prerequisites) **Setup time:** 20–45 minutes ### Key facts (verified) - README lists CLI commands (`query`, `chat`, `configs`, `validate`) and config routing behavior. - Quick start uses `uv sync --all-extras` and copies `.env.example` (README). - GitHub: 231 stars · 33 forks; pushed 2026-01-14 (GitHub API verified). ## Main ### Practical guardrails for NL2SQL agents Use read-only credentials until you have eval coverage, and log generated SQL + result shape for audits. ### README excerpt (verbatim)
```diff + ╔╦╗╔═╗╔╦╗╔═╗ ╔═╗╔═╗╔═╗╔╗╔╔╦╗ + ║║╠═╣ ║ ╠═╣ ╠═╣║ ╦║╣ ║║║ ║ + ═╩╝╩ ╩ ╩ ╩ ╩ ╩ ╩╚═╝╚═╝╝╚╝ ╩ [ Natural Language → SQL Query Agent ] ```
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) --- A natural language to SQL (NL2SQL) platform built on LangGraph and Azure OpenAI. This multi-agent system automatically routes user questions to the appropriate database backend and generates optimized SQL queries and results. Built on top of LangChain's [`SQLDatabase`](https://docs.langchain.com/oss/python/langchain/sql-agent) with extended support for Azure AD authentication, Cosmos DB, and built-in dialect validation. ## Features - **Multi-Database Support**: PostgreSQL, Azure SQL, Azure Synapse, Azure Cosmos DB, Databricks SQL, and Google BigQuery - **Intent Detection**: Automatically routes queries to the correct data agent based on question context - **Multi-Turn Conversations**: Follow-up questions with context awareness (e.g., "What's the average?" after a query) - **SQL Validation**: Safe query execution with sqlglot-based validation across all dialects - **Data Visualization**: Generate charts and graphs from query results using natural language (e.g., "show me a bar chart") - **Configurable Agents**: YAML-based configuration for adding new data sources - **A2A Protocol**: Agent-to-Agent interoperability for integration with other A2A-compliant systems ## Architecture ### Intent Detection Flow Routes user questions to the appropriate data agent based on context. ![Intent Detection Flow](docs/intent_detection_graph.png) ### Data Agent Flow Generates, validates, and executes SQL queries with retry logic. ![Data Agent Flow](docs/data_agent_graph.png) ## Documentation - [Database Setup](docs/DATABASE_SETUP.md) - [Configuration](docs/CONFIGURATION.md) - [Data Visualization](docs/VISUALIZATION.md) - [A2A Protocol](docs/A2A.md) ## Quick Start ### Prerequisites - Python 3.12+ - [uv](https://docs.astral.sh/uv/) package manager - Azure OpenAI deployment ### Installation ```bash git clone https://github.com/eosho/langchain_data_agent cd langchain_data_agent uv sync --all-extras cp .env.example .env # Edit .env with your values ``` ### CLI Usage The CLI provides commands for querying data agents through natural language. ```bash # Show available commands data-agent --help ``` **Commands:** | Command | Description | |---------|-------------| ### FAQ **Q: Do I need uv?** A: README lists uv as a prerequisite and uses `uv sync --all-extras` in install steps. **Q: Can it run interactively?** A: Yes—README includes `data-agent chat` as an interactive mode. **Q: How do I keep it safe?** A: Start with read-only DB users and add confirmation/evals before running expensive queries. ## Source & Thanks > Source: https://github.com/eosho/langchain_data_agent > License: MIT > GitHub stars: 231 · forks: 33 --- ## 快速使用 ```bash git clone https://github.com/eosho/langchain_data_agent cd langchain_data_agent uv sync --all-extras cp .env.example .env data-agent --help ``` ## 简介 langchain_data_agent 把自然语言问题变成 SQL,并提供 CLI 入口;它能按配置把问题路由到不同的专用数据 agent,适合把数据问答流程标准化。 **最适合:** 想用可复用配置 + CLI 快速原型 NL2SQL 助手的数据团队 **适配:** Python 3.12+ + uv;通过 `.env` 配置凭证(README 前置条件) **配置时间:** 20–45 分钟 ### 关键事实(已验证) - README 列出 CLI 命令(`query`/`chat`/`configs`/`validate`)以及按配置路由机制。 - Quick start 使用 `uv sync --all-extras` 并复制 `.env.example`(README)。 - GitHub:231 stars · 33 forks;最近更新 2026-01-14(GitHub API 验证)。 ## 正文 ### NL2SQL agent 的实用护栏 在评测覆盖不够之前使用只读凭证,并记录生成的 SQL 与结果结构,便于审计。 ### README 原文节选(verbatim)
```diff + ╔╦╗╔═╗╔╦╗╔═╗ ╔═╗╔═╗╔═╗╔╗╔╔╦╗ + ║║╠═╣ ║ ╠═╣ ╠═╣║ ╦║╣ ║║║ ║ + ═╩╝╩ ╩ ╩ ╩ ╩ ╩ ╩╚═╝╚═╝╝╚╝ ╩ [ Natural Language → SQL Query Agent ] ```
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) --- A natural language to SQL (NL2SQL) platform built on LangGraph and Azure OpenAI. This multi-agent system automatically routes user questions to the appropriate database backend and generates optimized SQL queries and results. Built on top of LangChain's [`SQLDatabase`](https://docs.langchain.com/oss/python/langchain/sql-agent) with extended support for Azure AD authentication, Cosmos DB, and built-in dialect validation. ## Features - **Multi-Database Support**: PostgreSQL, Azure SQL, Azure Synapse, Azure Cosmos DB, Databricks SQL, and Google BigQuery - **Intent Detection**: Automatically routes queries to the correct data agent based on question context - **Multi-Turn Conversations**: Follow-up questions with context awareness (e.g., "What's the average?" after a query) - **SQL Validation**: Safe query execution with sqlglot-based validation across all dialects - **Data Visualization**: Generate charts and graphs from query results using natural language (e.g., "show me a bar chart") - **Configurable Agents**: YAML-based configuration for adding new data sources - **A2A Protocol**: Agent-to-Agent interoperability for integration with other A2A-compliant systems ## Architecture ### Intent Detection Flow Routes user questions to the appropriate data agent based on context. ![Intent Detection Flow](docs/intent_detection_graph.png) ### Data Agent Flow Generates, validates, and executes SQL queries with retry logic. ![Data Agent Flow](docs/data_agent_graph.png) ## Documentation - [Database Setup](docs/DATABASE_SETUP.md) - [Configuration](docs/CONFIGURATION.md) - [Data Visualization](docs/VISUALIZATION.md) - [A2A Protocol](docs/A2A.md) ## Quick Start ### Prerequisites - Python 3.12+ - [uv](https://docs.astral.sh/uv/) package manager - Azure OpenAI deployment ### Installation ```bash git clone https://github.com/eosho/langchain_data_agent cd langchain_data_agent uv sync --all-extras cp .env.example .env # Edit .env with your values ``` ### CLI Usage The CLI provides commands for querying data agents through natural language. ```bash # Show available commands data-agent --help ``` **Commands:** | Command | Description | |---------|-------------| ### FAQ **一定要用 uv 吗?** 答:README 把 uv 列为前置条件,并在安装步骤使用 `uv sync --all-extras`。 **能交互式运行吗?** 答:能。README 有 `data-agent chat` 的交互模式。 **怎么更安全?** 答:先用只读用户,并在执行高风险查询前增加确认与评测。 ## 来源与感谢 > Source: https://github.com/eosho/langchain_data_agent > License: MIT > GitHub stars: 231 · forks: 33 --- Source: https://tokrepo.com/en/workflows/langchain-data-agent-nl2sql-data-agent-cli Author: Script Depot