Skip to main content
This is an example implementation of a SQL execution review workflow using Humancheck. This demonstrates how to integrate human review for database operations, but Humancheck can be used for any system operation that requires human approval.

Overview

The SQL execution review workflow:
  1. Agent generates SQL query
  2. System analyzes query for risk (destructive operations, data scope, etc.)
  3. If risky, request human review
  4. Reviewer approves, rejects, or modifies query
  5. System executes approved query

Implementation

Basic SQL Execution Review

Advanced Features

Query Validation

Read-Only Mode

Transaction Support

Routing Rules

Route SQL reviews to database administrators:

Dashboard Integration

The SQL execution request appears in the dashboard with:
  • SQL query (with syntax highlighting)
  • Database name
  • Risk level and score
  • Risk factors identified
  • Estimated affected rows
  • Query type (SELECT, DELETE, UPDATE, etc.)
Reviewers can:
  • ✅ Approve query for execution
  • ❌ Reject with reason
  • ✏️ Modify query (add WHERE clause, LIMIT, etc.) before approving

Best Practices

  1. Always review destructive operations: DELETE, DROP, TRUNCATE should always require review
  2. Check for WHERE clauses: Queries without WHERE clauses are dangerous
  3. Add LIMIT clauses: Encourage LIMIT clauses for safety
  4. Provide context: Show why the query is needed
  5. Use read-only mode: For SELECT queries, use read-only database connections
  6. Log all executions: Maintain audit trail of all SQL executions
  7. Test queries first: Use EXPLAIN or similar to show query plan

Security Considerations

  • Principle of least privilege: Use database users with minimal permissions
  • Parameterized queries: Always use parameterized queries to prevent SQL injection
  • Query timeouts: Set timeouts to prevent long-running queries
  • Connection limits: Limit number of concurrent connections
  • Backup before destructive ops: Consider requiring backups before destructive operations

Next Steps