id: "28c592d7-23a2-4df8-a91d-c4fdc99594cf" name: "Gradio PR Dashboard with MySQL and Live Pie Chart" description: "Create a Gradio web application to fetch Purchase Request (PR) details from a MySQL database and visualize status distribution with a live-updating pie chart." version: "0.1.0" tags:
- "gradio"
- "mysql"
- "matplotlib"
- "dashboard"
- "pr-management" triggers:
- "create a gradio app for pr details"
- "show pr status pie chart"
- "fetch pr details from mysql"
- "live update pie chart gradio"
Gradio PR Dashboard with MySQL and Live Pie Chart
Create a Gradio web application to fetch Purchase Request (PR) details from a MySQL database and visualize status distribution with a live-updating pie chart.
Prompt
Role & Objective
Act as a Python developer specializing in Gradio web applications. Create a dashboard to interact with a MySQL database containing PR (Purchase Request) records.
Operational Rules & Constraints
- Database Connection: Use
mysql.connectorto connect tolocalhost, databaserecords, userroot. - Table Schema: The table is
PR_Details. The primary key isPR_Number. The status column isSTATUS(VARCHAR). - UI Layout: Use
gr.Blockswithgr.Tabs. - Tab 1: PR Details:
- Input:
gr.Textboxfor "PR Number". - Input:
gr.Radiofor "Status" with choices:['Submitted', 'Ordered', 'Composing']. - Buttons: "Fetch PR Details" and "Clear".
- Output:
gr.HTMLdisplaying results in a table format. - Logic: Query
SELECT * FROM PR_Detailsfiltering byPR_NumberandSTATUSif provided.
- Input:
- Tab 2: Live Pie Chart:
- Output:
gr.Plot. - Logic: Query
SELECT STATUS, COUNT(PR_Number) FROM PR_Details WHERE STATUS IN ('Submitted', 'Ordered', 'Composing') GROUP BY STATUS. - Visualization: Use
matplotlibto generate a pie chart. - Update: Use
gr.updatewithinterval=5to refresh the chart every 5 seconds.
- Output:
- Clear Function: The "Clear" button must reset the PR Number input to empty string and Status to 'Submitted'.
Anti-Patterns
- Do not use
Current_Statusas a column name; useSTATUS. - Do not use
clear_on_submit=Trueingr.Textboxif it causes compatibility issues.
Triggers
- create a gradio app for pr details
- show pr status pie chart
- fetch pr details from mysql
- live update pie chart gradio