--- title: schemagate emoji: 🔒 colorFrom: green colorTo: gray sdk: gradio sdk_version: 6.26.0 python_version: '3.12' app_file: app.py pinned: false license: apache-2.0 short_description: Identity-scoped schema selection for text-to-SQL tags: - text-to-sql - nl2sql - rag - sql - security --- # schemagate Picks the handful of tables a text-to-SQL model needs, and filters them by who is asking — **before** the model sees anything. Schema selection runs before the query runs, so it runs before row-level security can act. A selector that is not identity-aware hands the model a table the caller cannot read: the SQL is correct, RLS filters every row, and the user is told *no records found*. A wrong answer in a confident tone, not an access-denied message. This Space runs the real selector over a bundled 42-object demo schema. No database, no API key, no model call — BM25 plus a hashed embedder, offline. `hr_compensation` is restricted to the `payroll` role: change the roles box and watch it appear and disappear from the prompt. ``` pip install schemagate schemagate demo "which customers owe us money" ``` - Source: https://github.com/ashishsinha1602/schemagate - PyPI: https://pypi.org/project/schemagate/ - Apache-2.0. Certified live on Oracle Autonomous Database 26ai and PostgreSQL 16.