Getting to google docs via code

Over the last few weeks, I've had the need to share data from applications I'm working on to interested parties.  In an ideal world, this access would be baked into the application through some sort of administrative UI.   However, anything non-trivial would certainly take a good bit of effort to not only create that UI but to administer it.  (user management and access control, for example)   When I better understand the long-term data reporting needs of the app, I'm sure I'll go down that road.  But for now, I just needed to share some basic data out from the app.

Spreadsheets are great for this type of data, and google docs has very sophisticated sharing mechanisms.  For one-time data sharing tasks, it's trivial to upload the results of a database query as CSV and share it with others.  However, I needed to keep this data current.   I really don't want to be manually uploading reports every day.

Google provides programmatic access via the Google Data Protocol.  With GData I can write code to push data to a shared document.  This is probably less work than a custom UI, but it's not exactly free.  It's a generic enough task that I think I might write a JDBC -> GData exporter at some point just for kicks, but I'm not there yet.  

Last week I stumbled across a scriptable Google docs upload tool.  With this tool, I was able to write a shell script that would run queries against the database and upload the output (as CSV) to google docs in a shared directory.  Cron makes sure that the script is run at regular intervals.  The net result is that I have an automated way to share data with interested parties in a format that they can work with.  I can trivially add new queries or reports, and managing users and access is simple.  

It's not a perfect solution, but it solved the immediate problem very quickly.  Aside from the hassle of trying to get a valid AuthSub token (I didn't want to put my username and password in the script) it took very little time to implement.