REST API | Treasure Data
REST API The user can control Treasure Data using the public REST API. This article will explain how...
http://docs.treasure-data.com/articles/rest-api
mattn/go-treasuredata ・ GitHub使い方はこんな感じ。
https://github.com/mattn/go-treasuredata
client := treasuredata.NewClient("TREASUREDATA-API-KEY")
job, _ := client.JobIssueHive("mydb", "select * from mytable")
client.JobResultFunc(job.JobId, func(row []interface{}) error {
fmt.Println(row)
return nil
})
結果は JSON で貰えます。データが大量に返る場合があるのでデータ取得はコールバックで行います。error を返せば途中で抜けられます。td フォルダにはコマンドラインツールが入っていて、クエリをコマンドラインから投げられます。
$ cd td
$ go build td.go
$ export TREASURE_DATA_API_KEY=xxxxxx
$ ./td -d mattn -q 'select * from unko'
["残念","小",{"size":"小","feel":"残念","time":"1363948092"},1363948092]
["残念","小",{"size":"小","feel":"残念","time":"1363948093"},1363948093]
["残念","小",{"size":"小","feel":"残念","time":"1363948094"},1363948094]
["残念","小",{"size":"小","feel":"残念","time":"1363948095"},1363948095]
["残念","小",{"size":"小","feel":"残念","time":"1363948096"},1363948096]
["残念","小",{"size":"小","feel":"残念","time":"1363948097"},1363948097]
["爽快","大",{"size":"大","feel":"爽快","time":"1363948098"},1363948098]
["残念","小",{"size":"小","feel":"残念","time":"1363948091"},1363948091]
["残念","小",{"size":"小","feel":"残念","time":"1363948092"},1363948092]
["残念","小",{"size":"小","feel":"残念","time":"1363948093"},1363948093]
["残念","小",{"size":"小","feel":"残念","time":"1363948094"},1363948094]
["残念","小",{"size":"小","feel":"残念","time":"1363948095"},1363948095]
["残念","小",{"size":"小","feel":"残念","time":"1363948096"},1363948096]
["残念","小",{"size":"小","feel":"残念","time":"1363948097"},1363948097]
["爽快","大",{"size":"大","feel":"爽快","time":"1363948098"},1363948098]
["残念","小",{"size":"小","feel":"残念","time":"1363948092"},1363948092]
["残念","小",{"size":"小","feel":"残念","time":"1363948093"},1363948093]
["残念","小",{"size":"小","feel":"残念","time":"1363948094"},1363948094]
["残念","小",{"size":"小","feel":"残念","time":"1363948095"},1363948095]
["残念","小",{"size":"小","feel":"残念","time":"1363948096"},1363948096]
["残念","小",{"size":"小","feel":"残念","time":"1363948097"},1363948097]
["爽快","大",{"size":"大","feel":"爽快","time":"1363948098"},1363948098]
["残念","小",{"size":"小","feel":"残念","time":"1363948091"},1363948091]
["残念","小",{"size":"小","feel":"残念","time":"1363948092"},1363948092]
["残念","小",{"size":"小","feel":"残念","time":"1363948093"},1363948093]
["残念","小",{"size":"小","feel":"残念","time":"1363948094"},1363948094]
["残念","小",{"size":"小","feel":"残念","time":"1363948095"},1363948095]
["残念","小",{"size":"小","feel":"残念","time":"1363948096"},1363948096]
["残念","小",{"size":"小","feel":"残念","time":"1363948097"},1363948097]
["爽快","大",{"size":"大","feel":"爽快","time":"1363948098"},1363948098]
毎日のウンコのサイズを treasure data に入れておいて、go-treasuredata で履歴を照会出来る様にしておけば健康管理もバッチリですね。