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
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:
- downloads a spreadsheet in TSV format
- creates a tmp table
- imports the TSV in the tmp table
- swaps the tmp table with the original table you want to import the spreadsheet to (this allows atomic operations on the DB)
and turns 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.