Instantly share code, notes, and snippets.

View try_new
try:
# 処理
expect client.expections.ClientError as e:
pass
View try_old
try:
# 処理
expect Exception as e:
if str(e) = 'エラー文':
pass
else:
print(e)
View sort_partition
SELECT * FROM "データベース名"."テーブル名"
where
dt = '2018/10/01'
order by numbytes desc limit 10
View create_partition
ALTER TABLE ap_northeast_1
ADD PARTITION (dt='2018/10/01')
location 's3://バケット名/AWSLogs/アカウント番号/vpcflowlogs/ap-northeast-1/2018/10/01';
View create_table
CREATE EXTERNAL TABLE IF NOT EXISTS データベース名.テーブル名 (
version int,
account string,
interfaceid string,
sourceaddress string,
destinationaddress string,
sourceport int,
destinationport int,
protocol int,
numpackets int,
View create_database
CREATE DATABASE データベース名
View lambda_function.py
import boto3
import datetime
def lambda_handler(event, context):
# タイムゾーンの生成
JST = timezone(timedelta(hours=+9), 'JST')
now = datetime.now(JST)
print(now.strftime("%Y/%m/%d")) #2018/10/02