llama-index-tools-database


Namellama-index-tools-database JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
Summaryllama-index tools database integration
upload_time2025-07-30 20:50:25
maintainerajhofmann
docs_urlNone
authorNone
requires_python<4.0,>=3.9
licenseNone
keywords aws rds postgres snowflake sql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-database/examples/database.ipynb).

Here's an example usage of the DatabaseToolSpec.

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-tools-database",
    "maintainer": "ajhofmann",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "aws rds, postgres, snowflake, sql",
    "author": null,
    "author_email": "Your Name <you@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/f0/89/7689dd218ecf927616f0c21d5b79fbc4bc2ddb4c91d05deb41827694f23b/llama_index_tools_database-0.4.0.tar.gz",
    "platform": null,
    "description": "# Database Tool\n\nThis tool connects to a database (using SQLAlchemy under the hood) and allows an Agent to query the database and get information about the tables.\n\n## Usage\n\nThis tool has more extensive example usage documented in a Jupyter notebook [here](https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-database/examples/database.ipynb).\n\nHere's an example usage of the DatabaseToolSpec.\n\n```python\nfrom llama_index.tools.database import DatabaseToolSpec\nfrom llama_index.core.agent.workflow import FunctionAgent\nfrom llama_index.llms.openai import OpenAI\n\ndb_tools = DatabaseToolSpec(\n    scheme=\"postgresql\",  # Database Scheme\n    host=\"localhost\",  # Database Host\n    port=\"5432\",  # Database Port\n    user=\"postgres\",  # Database User\n    password=\"FakeExamplePassword\",  # Database Password\n    dbname=\"postgres\",  # Database Name\n)\nagent = FunctionAgent(\n    tools=db_tools.to_tool_list(),\n    llm=OpenAI(model=\"gpt-4.1\"),\n)\n\nprint(await agent.run(\"What tables does this database contain\"))\nprint(await agent.run(\"Describe the first table\"))\nprint(await agent.run(\"Retrieve the first row of that table\"))\n```\n\nThe tools available are:\n\n`list_tables`: A tool to list the tables in the database schema\n`describe_tables`: A tool to describe the schema of a table\n`load_data`: A tool that accepts an SQL query and returns the result\n\nThis loader is designed to be used as a way to load data as a Tool in a Agent.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "llama-index tools database integration",
    "version": "0.4.0",
    "project_urls": null,
    "split_keywords": [
        "aws rds",
        " postgres",
        " snowflake",
        " sql"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ca36967075e153a30a3886d2ebf54110964180a4eccdb07379fccc798dec36c4",
                "md5": "bda8daf5a335ab04b5a420e9f37de470",
                "sha256": "c31ac502f9d639960d125b632b5aef1f39e49104f174bc26fd3b3fd3544ceaf9"
            },
            "downloads": -1,
            "filename": "llama_index_tools_database-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bda8daf5a335ab04b5a420e9f37de470",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 4529,
            "upload_time": "2025-07-30T20:50:24",
            "upload_time_iso_8601": "2025-07-30T20:50:24.592594Z",
            "url": "https://files.pythonhosted.org/packages/ca/36/967075e153a30a3886d2ebf54110964180a4eccdb07379fccc798dec36c4/llama_index_tools_database-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f0897689dd218ecf927616f0c21d5b79fbc4bc2ddb4c91d05deb41827694f23b",
                "md5": "523e588ae9810c2db350f3e1ba8f2a4d",
                "sha256": "932c13fc0451e05ff2b5166e6c99414f89409f6df490eb439bb3efd46d64361e"
            },
            "downloads": -1,
            "filename": "llama_index_tools_database-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "523e588ae9810c2db350f3e1ba8f2a4d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 4891,
            "upload_time": "2025-07-30T20:50:25",
            "upload_time_iso_8601": "2025-07-30T20:50:25.328631Z",
            "url": "https://files.pythonhosted.org/packages/f0/89/7689dd218ecf927616f0c21d5b79fbc4bc2ddb4c91d05deb41827694f23b/llama_index_tools_database-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-30 20:50:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-tools-database"
}
        
Elapsed time: 1.44394s