{
 "schema_version": 1,
 "generated": "2026-10-20",
 "id": "xu123-bob-baize--query-sql-database-with-pii-redaction",
 "repo": "Xu123-Bob/Baize",
 "repo_url": "https://github.com/Xu123-Bob/Baize",
 "repo_slug": "xu123-bob-baize",
 "title": "Query a SQL database while redacting personal data before the LLM sees it",
 "page_title": "How to query a SQL database while redacting personal data before the LLM sees it with Baize",
 "summary": "Ask questions about a PostgreSQL, MySQL, SQL Server, Oracle, or Dameng database with privacy protection on.",
 "who": "A data analyst who needs answers from a company database that contains phone numbers, emails, or ID numbers.",
 "problem": "Sending raw database rows with personal data to a cloud LLM exposes that data.",
 "outcome": "Baize queries the database through the RDBMS MCP server, redacts personal fields before the LLM sees them, and restores the original text in its answers.",
 "steps": [
  "`pip install -r requirements-data.txt`",
  "For SQL Server only: install Microsoft ODBC Driver 18 for SQL Server at the system level, because `pyodbc` alone is not enough.",
  "Add your database connection to the MCP server settings; the README names the MCP protocol but does not show the exact config format, so check the project documentation. (inferred, check the README)",
  "`baize`",
  "At the `>>> Decree:` prompt, type `/privacy` to confirm privacy protection is on, then ask your question about the database."
 ],
 "agent_prompt": "Using the Baize CLI from the Xu123-Bob/Baize repo with privacy protection on, ask it to count rows in <table-name> of <database-name> and summarize the result. Expected output: a row count and a short summary with no raw personal values. Verify that no phone number or email appears in the LLM-facing prompt log.",
 "agents": [
  "any"
 ],
 "difficulty": "Advanced",
 "time": "1.5 hours",
 "basis": "readme",
 "caveat": "The README does not show how to configure the RDBMS MCP server, so the connection step must be confirmed from the project documentation.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "javascript",
 "requirements": [
  "Python 3.10 or newer with pip",
  "An API key for DeepSeek or another supported backend, or a local Ollama install",
  "Optional: IBM SPSS Statistics or a reachable SQL database, depending on the use case"
 ],
 "risk": "sensitive",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [
  {
   "tag": "credentials",
   "notice": "Database connection details and passwords are required, and the README only describes where the LLM API keys are stored in `.env`, so confirm where database credentials are kept before you add them."
  }
 ],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/xu123-bob-baize/query-sql-database-with-pii-redaction/",
 "md": "https://dedupedai.com/use-cases/xu123-bob-baize/query-sql-database-with-pii-redaction/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/xu123-bob-baize--query-sql-database-with-pii-redaction.json",
 "api_version": "v1"
}
