質問編集履歴

3

文章の修正

2023/01/27 01:15

投稿

watchdogs
watchdogs

スコア54

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,9 @@
1
1
  ### 前提
2
2
 
3
3
  AWS LamdaでDynamoDBのデータベースを取得したいのですがエラーが出て困っています。
4
+ dynamodb_nameのDBをすべてラムダで読み込みたいのですが、
5
+ カラム情報がうまく読み込めていないようで躓いています。
6
+ ご教授頂けますと助かります。
4
7
 
5
8
  環境:Python
6
9
  コーディングでの参考にしたサイト

2

プログラム修正

2023/01/27 01:07

投稿

watchdogs
watchdogs

スコア54

test CHANGED
File without changes
test CHANGED
@@ -7,25 +7,18 @@
7
7
  https://qiita.com/stpete_ishii/items/7d5d7f1a6f82cc2c3b58
8
8
 
9
9
 
10
-
11
-
12
- ### 該当のソースコード
13
-
14
- ```ここに言語名を入力
15
- ソースコード
16
- ```
17
-
18
10
  ### 試したこと
19
11
 
20
12
  ```Python
21
- #dynamoDBからデータ取得----------------------------------------------------------------------------------
13
+ #dynamoDBからデータ取得----------------------------------------------------------------------------------
14
+ import boto3
22
-   dynamodb = boto3.resource('dynamodb', region_name='ap-northeast-1')
15
+ dynamodb = boto3.resource('dynamodb', region_name='ap-northeast-1')
23
- table = dynamodb.Table("dynamodb_name")
16
+ table = dynamodb.Table("dynamodb_name")
24
- partition_key = {'unitid': event['unitid']}#主キーを入れているがエラーになる
17
+ partition_key = {'unitid': event['unitid']}#主キーを入れているがエラーになる
25
- dynamotable = dynamodb.Table(table)
18
+ dynamotable = dynamodb.Table(table)
26
- res = dynamotable.get_item(Key=partition_key)
19
+ res = dynamotable.get_item(Key=partition_key)
27
- item = response['Item']
20
+ item = response['Item']
28
- print(item)
21
+ print(item)
29
22
  ```
30
23
 
31
24
  ### 発生している問題・エラーメッセージ

1

プログラム修正

2023/01/27 00:36

投稿

watchdogs
watchdogs

スコア54

test CHANGED
File without changes
test CHANGED
@@ -21,7 +21,7 @@
21
21
  #dynamoDBからデータ取得----------------------------------------------------------------------------------
22
22
    dynamodb = boto3.resource('dynamodb', region_name='ap-northeast-1')
23
23
  table = dynamodb.Table("dynamodb_name")
24
- partition_key = {'#######': event['#######']}#主キーを入れているがエラーになる
24
+ partition_key = {'unitid': event['unitid']}#主キーを入れているがエラーになる
25
25
  dynamotable = dynamodb.Table(table)
26
26
  res = dynamotable.get_item(Key=partition_key)
27
27
  item = response['Item']