schemagate icon
schemagate icon

schemagate

Open-source Python library that filters a database schema by caller identity before SQL is generated, so a text-to-SQL model is never shown a table the user is not allowed to read.

schemagate screenshot 1

Cost / License

Platforms

  • Self-Hosted
  • Python
  • Linux
Alternatives
0likes
0alternatives
0articles

Features

No features, maybe you want to suggest one?

schemagate News & Activities

Highlights All activities

Recent activities

schemagate information

AlternativeTo Category

Development

GitHub repository

  •  3 Stars
  •  0 Forks
  •  6 Open Issues
  •   Updated  
View on GitHub
schemagate was added to AlternativeTo by sinhaashish on and this page was last updated .
No comments or reviews, maybe you want to be first?

What is schemagate?

schemagate is an Apache-2.0 Python library for the schema-selection step of text-to-SQL and NL2SQL systems.

Most stacks let the model see the whole schema, or a retrieved subset of it, and apply access control later when the query runs, via row-level security or a permissions layer. That protects the data but not the answer: the model writes valid SQL against a table the caller cannot read, the filter strips every row, and the user is told "no records found" — which is false and indistinguishable from the table being empty.

schemagate decides what the model is shown per caller, before any SQL exists. A restricted table is absent from the prompt rather than ranked lower or filtered afterwards. Table-level and column-level restrictions are both supported, so a table can be visible with a column withheld.

It is not a platform or a chat UI. It replaces the schema-selection step; you keep whatever writes your SQL.

  • Reflects any SQLAlchemy database (PostgreSQL, Oracle, SQLite, MySQL, SQL Server)
  • Fielded BM25 plus vector hybrid ranking; no API key required
  • Writes nothing to your database: no embeddings table, no schema changes
  • Ships an MCP server, a LangChain retriever, a CLI and a browser Studio
  • Optional local sentence-transformer embedder; runs fully offline

Live-tested on PostgreSQL 16, Oracle 26ai and SQLite. SQL Server and MySQL reflect but have not yet been run against a live instance.

pip install schemagate