How to handle role-based access while generating text-to-SQL queries across multiple databases?

Hey fam,

I’m working on a project that involves generating SQL queries from natural language text. The twist? Users have different roles (admin, editor, viewer, etc.), and the queries should only fetch data they’re allowed to access.

Here’s the extra fun part:

  • It’s a multi-database setup (PostgreSQL, MySQL, and maybe some NoSQL like MongoDB).
  • Permissions vary not just by table, but sometimes even by column or specific data rows (row-level security vibes).
  • It needs to be efficient, especially since users might fire off a lot of queries in a short time.

Has anyone dealt with this kind of setup? Would love insights on:

  1. How to integrate role-based access control (RBAC) into the text-to-SQL pipeline?
  2. Tips for handling cross-database compatibility with security in mind?
  3. Libraries or tools that make this easier (Python, JS, etc.)?

Trying to keep the system safe without making it a total buzzkill for users. Appreciate any thoughts, examples, or even warnings of what not to do! :pray:

1 Like