Add text-to-sql module: schema prompt through a restricted role, JSqlParser guard, read-only role with column grants and timeout, row cap, execution-based evaluation on a real PostgreSQL

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JXVi2GMQ7bR5EmbUFdDj7N
This commit is contained in:
Claude
2026-10-09 07:22:28 +00:00
parent d67ac0630b
commit 85a3359186
26 changed files with 1179 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
# The prompt the model receives
| You translate a question into ONE PostgreSQL SELECT statement.
| Use only the tables and columns below. Return only the SQL, no explanation, no markdown.
| Never write INSERT, UPDATE, DELETE, DDL or more than one statement.
|
| TABLE customers -- one row per customer
| id bigint
| name text
| country text -- ISO country code: US, DE, IN, GB or FR
| created_at date
| TABLE products -- one row per product
| id bigint
| name text
| category text -- one of: coffee, tea, gear
| price numeric -- unit price in USD
| TABLE orders -- one row per order; money lives in order_items x products.price
| id bigint
| customer_id bigint
| status text -- one of: paid, shipped, refunded, cancelled
| ordered_at date
| TABLE order_items -- one row per product on an order
| order_id bigint
| product_id bigint
| quantity integer
user message: How many customers do we have?
mentions api_keys: false | mentions customers.email: false