Querying Your Google Calendar

September 12th, 2018


Regular Expressions

Just like regular expressions, once you know SQL, you basically want SQL access to all structured data. Your emails, fitness tracking, work patterns…and your calendar. I had the good excuse to do this for calendars (hence my post yesterday) and I figure it’s worth sharing.

The ics2db README outlines the basics. Once you’ve got it working, here’s some example queries you might want to run.

How many meetings (with other people) do I have per month?

select timestamp_trunc(cast(start as timestamp), month), count(1) as events from google_calendar.events where array_length(attendees) > 1 group by 1;

Eric's events

Who’s inviting me to the most meetings?

select organizer, count(1) from google_calendar.events where array_length(attendees) > 1 group by 1;

Future Work

If enough people are interested (basically, at least 3-4 people), I can build versions of this. Ping @ehfeng if you’d like to see these built.

  1. Support local ical files (especially for work calendars where admin settings prevent sharing via link)
  2. Easier install via pip instead of cloning
  3. Support for automatically uploading to BigQuery
  4. Support for Postgres