Aita
  • Introduction
  • Roadmap
  • Aita Lab
    • Chat
    • Data Source
  • Architecture
  • Contribution
  • Getting Started
    • Quick Start
  • Installation
  • Reference
    • Aita agent
      • Pandas Agent
      • Pyarrow Agent
      • Python Agent
      • Spark Agent
      • SqlAgent
    • Data Sources
      • sql
      • File Data Source
      • Postgres Data Source
      • Snowflake Data Source
    • Aita tool
      • PythonTool
      • PandasTool
      • PyArrow Tool
      • pyspark tool
      • Sql Tools
  • Tech specs
    • Aita tech spec v1
Powered by GitBook
On this page
  1. Reference
  2. Aita agent

SqlAgent

The SqlAgent can be used to ask questions in natural language and interact with SQL databases.

Example

Pass Data Source to SqlAgent and analyze the data.

python
from aita.agent.sql import SqlAgent
from aita.datasource.postgresql import PostgreSqlDataSource
from aita.prompt.base import BasicContextPromptTemplate

postgres_datasource = PostgreSqlDataSource("postgresql://localhost:5432/db")
sql_agent = SqlAgent("gpt-3.5-turbo")
.set_context_prompt(BasicContextPromptTemplate)
.add_datasource(postgres_datasource)
sql_agent.stream("Get the top 10 customers by purchase amount")

{% endcode}

PreviousSpark AgentNextData Sources

Last updated 10 months ago