ablog

不器用で落着きのない技術者のメモ

AWS SDK for Python を使ってみる

  • boto3 をインストールする。
$ sudo pip install boto3
  • s3_ls.py
import os
import boto3
s3 = boto3.resource('s3')
mybucket = s3.Bucket('az-test-datalake')
for object in mybucket.objects.all():
    print(object)
  • 実行する
$ python s3_ls.py
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180101.txt')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180102.txt')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180103.txt')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180104.txt')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180105.txt')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180106.txt')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180107.txt')
s3.ObjectSummary(bucket_name='az-test-datalake', key=u'system01/table01/table01_20180108.txt')


ところで boto の名前の由来は

https://github.com/boto/boto3/issues/1023

boto = Amazon river dolphin
issue の会話を読んでいくと、アマゾン川に生息する アマゾンカワイルカ にちなんで boto と名付けられたみたい。

https://reboooot.net/post/why-boto/

Boto is a Portuguese name given to several types of dolphins and river dolphins native to the Amazon and the Orinoco River tributaries. A few botos exist exclusively in fresh water, and these are often considered primitive dolphins.

Boto - Wikipedia