sqltool

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sqltool provides SQL database query tools for agents. It enables agents to query PostgreSQL, MySQL, and SQLite databases using SQL, making structured data accessible through natural language workflows.

Problem: Agents frequently need to answer data questions like "how many users signed up this week?" or "what's the average order value?" Without this tool, agents cannot access relational databases and must rely on stale training data or ask humans to run queries manually.

Safety guards:

  • Read-only by default (only SELECT, SHOW, DESCRIBE, EXPLAIN allowed)
  • Query timeout (30 seconds) prevents runaway queries
  • Output truncated at 32 KB to limit LLM context consumption
  • Row limit (1000) prevents massive result sets
  • No credentials stored — DSN passed per-request or via config

Dependencies:

  • psql CLI (PostgreSQL) — install: brew install postgresql / apt-get install postgresql-client
  • mysql CLI (MySQL) — install: brew install mysql-client / apt-get install mysql-client
  • sqlite3 CLI (SQLite) — install: brew install sqlite / apt-get install sqlite3
  • No Go database drivers required (uses exec-based approach)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSQLTools

func NewSQLTools(name string, secretProvider security.SecretProvider) *sqlTools

Types

type ToolProvider

type ToolProvider struct {
	// contains filtered or unexported fields
}

ToolProvider wraps the SQL query tool and satisfies the tools.ToolProviders interface.

func NewToolProvider

func NewToolProvider(secretProvider security.SecretProvider) *ToolProvider

NewToolProvider creates a ToolProvider for the SQL query tool.

func (*ToolProvider) GetTools

func (p *ToolProvider) GetTools(name string) []tool.Tool

GetTools returns the SQL query tool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL