llama-index tools database integration
Project description
Database Tool
This tool connects to a database (using SQLAlchemy under the hood) and allows an Agent to query the database and get information about the tables.
Usage
This tool has more extensive example usage documented in a Jupyter notebook here.
Here's an example usage of the DatabaseToolSpec.
from llama_index.tools.database import DatabaseToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
db_tools = DatabaseToolSpec(
scheme="postgresql", # Database Scheme
host="localhost", # Database Host
port="5432", # Database Port
user="postgres", # Database User
password="FakeExamplePassword", # Database Password
dbname="postgres", # Database Name
)
agent = FunctionAgent(
tools=db_tools.to_tool_list(),
llm=OpenAI(model="gpt-4.1"),
)
print(await agent.run("What tables does this database contain"))
print(await agent.run("Describe the first table"))
print(await agent.run("Retrieve the first row of that table"))
The tools available are:
list_tables: A tool to list the tables in the database schema
describe_tables: A tool to describe the schema of a table
load_data: A tool that accepts an SQL query and returns the result
This loader is designed to be used as a way to load data as a Tool in a Agent.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_tools_database-0.4.1.tar.gz.
File metadata
- Download URL: llama_index_tools_database-0.4.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a024208163009131182322c5a82ccea6d53fcdfe20da131c74fa22c8a149ed5
|
|
| MD5 |
aa9fe9b1a3624d6bda773a7e3c8e278a
|
|
| BLAKE2b-256 |
b010084213e8d0865ab229733580d56de58428f5422747bb3c5580f619bdd5e4
|
File details
Details for the file llama_index_tools_database-0.4.1-py3-none-any.whl.
File metadata
- Download URL: llama_index_tools_database-0.4.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d2463a7c3b27763ca1e1f89e90a97d0c186a253525ccd933649061882046903
|
|
| MD5 |
2d4c2d4da555183c50eaa262618baa2c
|
|
| BLAKE2b-256 |
904428d797612f9e7f5d3d69ac43698a0ec977709cd633d8bad54fed191dca60
|