File size: 1,652 Bytes
11b47b6
 
 
 
 
 
e67b4b5
11b47b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---

title: DataBot ERP Assistant
emoji: πŸ€–
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: "5.20.0"
app_file: app.py
pinned: false
license: mit
---


# DataBot – ERP Database Assistant

DataBot lets you ask **natural-language questions** about your ERP database.
It uses GPT-4o to translate your question into SQL, executes it safely on your
MySQL database, and returns a plain-English summary.

## Features

- Natural-language β†’ SQL β†’ plain-English answers  
- Whitelist-based table access control (`data_access_config.json`)  
- Blocks all write operations (INSERT / UPDATE / DELETE / DROP …)  
- Masks sensitive columns (passwords, IBAN, salary, PII)  
- Schema cached at startup for fast responses  

## Setup (Hugging Face Spaces)

Set the following **Secrets** in your Space settings
(*Settings β†’ Variables and secrets β†’ New secret*):

| Secret name    | Description                           |
|----------------|---------------------------------------|
| `DB_USER`      | MySQL username                        |
| `DB_PASSWORD`  | MySQL password                        |
| `DB_HOST`      | MySQL host IP / domain                |
| `DB_NAME`      | Database name (default: `dev_poly`)   |
| `OPENAI_API_KEY` | Your OpenAI API key                 |
| `LLM_MODEL`    | Model to use (default: `gpt-4o`)      |

## Local Development

```bash

# 1. Clone the repo and create .env

cp .env.example .env   # fill in your credentials



# 2. Install dependencies

pip install -r requirements.txt



# 3. Run locally

python app.py

```

Then open http://localhost:7860 in your browser.