LoginSignup
2
3

More than 5 years have passed since last update.

ColaboratoryでTreasure Data にクエリを投げる

Last updated at Posted at 2017-11-13

Colaboratoryというhosted Jupyter + Google Driveなど連携などがされた便利なサービスがfree to useで提供されています。

Is it free to use?
Yes. Colaboratory is a research project that is free to use.
https://research.google.com/colaboratory/faq.html

なので、下記の手順でTreasure Dataにクエリを投げれます。

Colaboratoryでは任意のライブラリをインストールするには、!pip installを利用します。
つまり、

!pip install td-client

で、https://github.com/treasure-data/td-client-python のインストールが可能です。

あとは、下記のようにしてクエリが投げれますね。簡単。

import tdclient

with tdclient.Client(apikey='<YOUR APIKEY>') as td:
    job = td.query("sample_datasets", "SELECT COUNT(1) FROM www_access", type="presto")
    job.wait()
    for row in job.result():
        print(repr(row))

Untitled0_ipynb_-_Colaboratory.png

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3