atux_null
Posts: 132
Joined: Thu Jun 21, 2012 1:58 pm

google contacts to mysql sync

Thu Mar 23, 2017 7:20 am

i am running a LAMP server. I would like to sync once a day all my google contacts to mysql so i could retrieve it locally for different functions and operations. The update will be one way only, from google to mysql. Not the other way.I am afraid i cannot find a working solution to my issue. I am not sure if this is the right section of the forum. In such a case please let me know of what actions to take.

321a
Posts: 56
Joined: Fri Mar 17, 2017 11:07 pm

Re: google contacts to mysql sync

Thu Mar 23, 2017 12:17 pm

Maybe you could download the contacts from google using some sort of HTML automation, maybe like wget or something more geared to webpage automation & scraping, and then parse the HTML files into a flat file like csv, tab delimited or txt type of file and then create a stored procedure which imports the file into MySQL that way.

Once the individuals steps work ok, call them from a bigger script and create a scheduled entry in Cron to run daily.

Dont forget to delete the old files once completed to clean up.

FlexibleSigmoid
Posts: 61
Joined: Sun Jul 03, 2016 1:33 am

Re: google contacts to mysql sync

Thu Mar 23, 2017 4:56 pm

Does the ability to use CardDAV make the job a bit easier for you? Some hints here: https://developers.google.com/google-ap ... g_contacts

scotty101
Posts: 3782
Joined: Fri Jun 08, 2012 6:03 pm

Re: google contacts to mysql sync

Thu Mar 23, 2017 5:43 pm

There is a google contacts API so you don't have to go though the pain of scraping the HTML.

https://developers.google.com/google-apps/contacts/v3/

It has python examples to retrieve your entire contact list.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “General discussion”