Python Gmail MySQL Automation Script

Замовник: AI | Опубліковано: 01.03.2026

I need a fresh Python script that can log in to a Gmail account from a Linux server (Ubuntu 20.04) without any manual intervention, pull the messages I specify, and insert the parsed results straight into a MySQL database. Nothing is written yet, so you’ll be starting from a clean slate and structuring the whole flow—from authentication to data persistence. Here’s what I expect: • Reliable Gmail authentication that can run head-less on the server (OAuth2 preferred, but suggest the safest approach that avoids regular re-consent). • A modular extractor so I can choose which pieces of each email we save: at minimum I need unread messages, and I’d like the option to extend to attachments or full headers later without a full rewrite. • Clean insertion into a dedicated MySQL table. Please include a schema proposal and make sure your code parameterizes queries to avoid SQL injection. • Logging and basic error handling so I can track failed logins or parsing hiccups from systemd or Cron. • Straightforward instructions to deploy the script, set up the Gmail API credentials, and schedule the job. If you have experience with Gmail API, imaplib, or similar libraries on Linux, and you’re comfortable designing a minimal but extensible MySQL schema, let’s talk.