Skip to main content

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.agent.openai import OpenAIAgent

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 = OpenAIAgent.from_tools(db_tools.to_tool_list())

agent.chat("What tables does this database contain")
agent.chat("Describe the first table")
agent.chat("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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_database-0.3.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file llama_index_tools_database-0.3.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_tools_database-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8bbce16005b99a311912e9fee3c087a8db2beaeb0855e20ebb808fee00047d44
MD5 43eae513258b12c7637390183a9ae2d4
BLAKE2b-256 cfc1f7a3cac198cbd08f9a1624f944ea80692c55a9daa3bbae777a54dcc49a50

See more details on using hashes here.

File details

Details for the file llama_index_tools_database-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_database-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7820fb960dca18bbbc78e330a68769b97c73c514f26a813c47fc7cbb3870dc3
MD5 51130ab3be37cd89cbcaa43e6477b6bf
BLAKE2b-256 482b7dd5118365de6d82e5bbc90081538e46abe255ee8f48f6dbabcdb5b4b64b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page