4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SageMaker Studio Lab から Snowflake にシュッとつないで作業開始する

Last updated at Posted at 2021-12-08

SageMaker Studio Lab 出ましたね!

SageMaker Studio Lab ついに出ましたね!
Google の Clabo っぽいと話題になりましたが、イマイチGoogleが信用できない皆様には待望の無料Labなんじゃないでしょうか?

まだプライベートプレビュー的な扱いで、利用するにはリクエストが必要ですが、私の場合は比較的早く利用案内のメールが届きましたので、興味のある方はリクエストを投げてみてください。

SageMaker Studio Lab:https://studiolab.sagemaker.aws/

ログインするとこんな画面です

SageMaker_Studio_Lab.png

では Start runtime を押して始めていきましょう!
※押すと1分くらいで起動されるようです。Studioより少し早いかな?

では行ってみましょう

だいたいデータはDWHに入ってることが増えてきてるのかなと思います。
なので、今日は Snowflake にシュッとつないでみましょう。

!pip install --upgrade snowflake-connector-python

Untitled_ipynb_-_JupyterLab.png

シュシュッ

import snowflake.connector

user='HOGE_USER'
password='HOGE_PASSWD'
account='hogehoge.ap-northeast-1.aws'

ctx = snowflake.connector.connect(
    user=user,
    password=password,
    account=account
    )
cs = ctx.cursor()
try:
    cs.execute("SELECT current_version()")
    one_row = cs.fetchone()
    print(one_row[0])
finally:
    cs.close()
ctx.close()

Untitled_ipynb__2__-_JupyterLab.png

完璧だ!できてしまった!
メチャクチャ簡単ですね。

まとめ

SageMaker Studio Lab は無料なので、色々使ってみて、可能性を探してみましょう。
Google Colab と違ってTPUは使えないですし、まだ Colab のほうがハードルが低いかなと思いますが、 選択肢の一つとして持っておいてもいいのかもしれません。

もちろん Snowflake にも繋がります。

4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?