Issues syncing Google Calendar with a Python script

Supporting 2.7 and 3.2+
Welson
Phidgetsian
Posts: 5
Joined: Fri Oct 03, 2025 3:49 am

Issues syncing Google Calendar with a Python script

Post by Welson »

Hi everyone
I'm working on a small Python project that syncs events from a local SQLite database to Google Calendar. The basic setup works fine: the script reads events from SQLite and creates or updates them through the Google Calendar API. Authentication isn't really an issue anymore since I've already got token refresh working correctly with the official google-api-python-client. The part I'm struggling with is conflict handling. Let's say I update an event from my phone in Google Calendar and then make changes to the same event in my local application before the next sync runs. In some cases I end up with duplicate events, and in others one version simply overwrites the other without any warning. My first approach was to compare the updated timestamps returned by the API and keep whichever version was modified most recently. In theory that sounded straightforward, but in practice it has been messy. My machine runs in UTC, my personal calendar uses Europe/Paris, and I've run into a few situations where the timestamps don't seem to behave the way I expect. I've already switched to timezone-aware datetimes and normalised everything to UTC using dateutil, which improved things a bit, but I still get occasional edge cases that are difficult to reproduce consistently. For those of you who have built a reliable sync process with Google Calendar, how do you handle concurrent edits? Do you rely on timestamps alone, use some sort of revision tracking, or keep extra metadata to detect conflicts? Also, are there any libraries or established patterns that make this easier, or is this one of those problems where you eventually have to build your own conflict-resolution logic?
Any advice or real-world experience would be appreciated.