Import a Google spreadsheet into a MySQL table with docsql

There’s a lot of open-source software I’m not proud of; probably, though, nothing compares to docsql, as this rare piece of Golang qualifies as one of the weirdest of my creations.

At Namshi, we’ve been using spreadsheets as a mean of configuration for quite some time — you tell the stakeholder “hey, here’s a google doc, if you need to change one of the translations just edit the doc and wait 5 mins” and the bets are down.

Sometimes we actually need to import this data into MySQL (could be a una-tantum import as well as a scheduled job) and we traditionally did this manually, by pulling down a .tsv export from Google docs, amending it and running something such as LOAD DATA LOCAL INFILE.

One evening, I found myself wifeless and with a strong desire to try out cobra and viper, so I started to look into automating the process of importing a spreadsheet hosted on Google Docs into a MySQL table: the result was docsql, a small piece of weird software that simply:

and turns this:

into this:

Considering this was a funny experiment to try to automate a task I do quite infrequently1, I don’t think I’m going to spend a lot more time expanding it or adding random features2, but I’m happy to share the source code as I was pleasantly surprised with how straightforward it was to build such a small, isolated CLI tool.

  1. Even if infrequent, it’s still a pain
  2. Especially considering my good old love for the Unix philosophy of “do one thing and do it well…”

Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 160+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $9.99

In the mood for some more reading?

...or check the archives.