3
我正在使用Python中的boto
庫連接到DynamoDB。下面的代碼已經爲我工作得很好:Amazon DynamoDB - 特定於區域的連接
import boto
key = 'abc'
secret = '123'
con = boto.connect_dynamodb(key,secret)
table = con.get_table('Table Name')
-- rest of code --
當我嘗試連接到一個特定的區域,我可以連接就好了,但得到的表上工作時拋出一個錯誤:
import boto
from boto.ec2.connection import EC2Connection
key = 'abc'
secret = '123'
regions = EC2Connection(key,secret).get_all_regions() # some filtering after this line to remove unwanted entries
for r in regions:
con = boto.connect_dynamodb(key,secret,region=r)
table = con.get_table('Table Name') # throws the error below
-- rest of code --
使用上面的第二個代碼塊,我得到一個ValueError: No JSON object could be decoded
。調用con.list_tables()
顯示了我在第一個代碼塊中查找的表格,但在第二個代碼塊中嘗試它時會引發相同的錯誤。誰能幫我嗎?