質問編集履歴
3
文章の修正
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
プログラム修正
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
|
-
|
13
|
+
#dynamoDBからデータ取得----------------------------------------------------------------------------------
|
14
|
+
import boto3
|
22
|
-
|
15
|
+
dynamodb = boto3.resource('dynamodb', region_name='ap-northeast-1')
|
23
|
-
|
16
|
+
table = dynamodb.Table("dynamodb_name")
|
24
|
-
|
17
|
+
partition_key = {'unitid': event['unitid']}#主キーを入れているがエラーになる
|
25
|
-
|
18
|
+
dynamotable = dynamodb.Table(table)
|
26
|
-
|
19
|
+
res = dynamotable.get_item(Key=partition_key)
|
27
|
-
|
20
|
+
item = response['Item']
|
28
|
-
|
21
|
+
print(item)
|
29
22
|
```
|
30
23
|
|
31
24
|
### 発生している問題・エラーメッセージ
|
1
プログラム修正
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 = {'
|
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']
|