Python Prompts Free Prompt

Python Script to Generate Monthly Reports from Database

Create a Python script that generates monthly sales reports from a database
☆ Save
Prompt
You are a Python developer. Write a script that connects to a PostgreSQL/MySQL database, runs a query to aggregate monthly sales, and generates a PDF report with charts. Use libraries: psycopg2, matplotlib, reportlab. The script must: 1) Accept month and year as parameters, 2) Fetch data from orders table, 3) Calculate totals, 4) Generate a bar chart, 5) Create a PDF with summary and chart, 6) Email the report to a list of recipients, 7) Log the process. Add error handling and comments.

How to use this prompt

1
Click Copy Prompt above to copy to your clipboard.
2
Open ChatGPT, Claude, Gemini, or any AI assistant and paste the prompt.
3
Replace any [PLACEHOLDER] values with your specific details.
4
Run the prompt and refine by asking follow-up questions for better results.