Tuesday 18 February 2014

Connect Google Docs to a MySQL Server

Needed some quick and dirty reports from a MySQL Server based website to a User that used Google docs.

Found this
https://developers.google.com/apps-script/guides/jdbc#reading_from_a_database

Open a Google spreadsheet click Tools->Script Manager create a new script and paste. Change host, instance (Schema), user and password and put some SQL in and you are done Googles end. Then you need to enable your server to let in Googles servers. There may be a more secure way than this using netmasks but this worked for me.

Create users with ip ranges of Googles servers to keep out the nasties.

Screenshot from 2014-02-18 15:57:07

When you run foo it copies data into the root of the spreadsheet.