Sql Query Tool
Execute read-only SQL queries against PostgreSQL databases for data analysis
Quick Start
import { SQLQueryTool } from '@bubblelab/bubble-core';
import { CredentialType } from '@bubblelab/shared-schemas';
const result = await new SQLQueryTool({
query: 'example', // SQL query to execute (SELECT, WITH, EXPLAIN, ANALYZE, SHOW, DESCRIBE only)
reasoning: 'example', // Explain why you're running this specific query and what you hope to learn from it
credentials: {
[CredentialType.DATABASE_CRED]: process.env.DATABASE_URL as string,
},
}).action();
Operation Details
execute
- Input Schema
- Output Schema
querystring required- SQL query to execute (SELECT, WITH, EXPLAIN, ANALYZE, SHOW, DESCRIBE only)
reasoningstring required- Explain why you're running this specific query and what you hope to learn from it
credentialsRecord<CredentialType,string>- Database credentials (injected at runtime)
configRecord<string,unknown>- Configuration for the tool bubble
rowsRecord<string,unknown>[]- Array of query result rows as objects
rowCountnumber required- Number of rows returned by the query
executionTimenumber required- Query execution time in milliseconds
fieldsobject[]- Array of column metadata from the query result
successboolean required- Whether the query execution was successful
errorstring required- Error message if query execution failed