Natural Language Postgres
Query PostgreSQL databases using natural language. The agent translates your questions into SQL and returns results.Quick Start
Configuration
As Agent Tool
Schema Introspection
Query Examples
Query Result
Safety Features
Read-Only Mode (Default)
Table Restrictions
Parameterized Queries
All generated SQL uses parameterized queries to prevent SQL injection.Write Operations (Use with Caution)
Environment Variables
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection URL |
OPENAI_API_KEY | Yes | For NL to SQL translation |
Connection URL Format
Best Practices
- Always use read-only mode unless writes are necessary
- Whitelist tables to limit access
- Set row limits to prevent large result sets
- Review generated SQL before executing in production
- Use connection pooling for high-traffic applications
Related
- Database - Database adapters
- Agent Tools - Creating custom tools

