|
|
--- |
|
|
description: |
|
|
globs: |
|
|
alwaysApply: false |
|
|
--- |
|
|
|
|
|
|
|
|
This document outlines the guidelines for executing database queries and interacting with the database in the AI-powered interface. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Implemented in [postgre_mcp_server.py](mdc:postgre_mcp_server.py) |
|
|
- Supports read-only SQL queries (SELECT, COUNT, GROUP BY, ORDER BY) |
|
|
- Destructive operations (DELETE, UPDATE, INSERT, DROP) are not allowed |
|
|
- SQL syntax validation before execution |
|
|
- Query results are formatted for display |
|
|
|
|
|
|
|
|
- Asynchronous connection management using AsyncPG |
|
|
- Connection pooling for efficient resource utilization |
|
|
- Error handling for connection issues |
|
|
- Secure database URL management |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Use explicit column names instead of * |
|
|
- Include LIMIT clauses to restrict result sets |
|
|
- Add WHERE clauses to filter results |
|
|
- Consider indexing for performance |
|
|
- Format SQL with proper indentation and line breaks |
|
|
|
|
|
|
|
|
- Efficient use of connection pooling |
|
|
- Asynchronous query execution |
|
|
- Proper error handling and logging |
|
|
- Resource cleanup after query execution |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Invalid SQL syntax |
|
|
- Table or column not found |
|
|
- Connection failures |
|
|
- Query timeout |
|
|
- Resource constraints |
|
|
|
|
|
|
|
|
- Graceful error messages |
|
|
- Fallback responses |
|
|
- Automatic retry mechanisms |
|
|
- User-friendly error explanations |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Query execution logs |
|
|
- Performance metrics |
|
|
- Error tracking |
|
|
- Resource utilization |
|
|
- Response time monitoring |
|
|
|