0

저는 Dynamo & Python으로 작업 해 왔지만 지금은 구문이 일치하지 않는 것으로 보입니다.올바른 수정 본 aws DynamoDb .scan 구문

내가 읽어

# All results. 
>>> everything = users.scan() 

# Look for last names beginning with "D". 
>>> results = users.scan(last_name__beginswith='D') 
>>> for res in results: 
...  print res['first_name'] 
'Alice' 
'John' 
'Jane' 

# Use an ``IN`` filter & limit. 
>>> results = users.scan(
...  age__in=[25, 26, 27, 28, 29], 
...  limit=1 
...) 
>>> for res in results: 
...  print res['first_name'] 
'Alice' 

에서 : 문제가에 달려있다 https://github.com/boto/boto/blob/433f211b5eb93560916a4bd4a1dbf905e6c13a58/boto/dynamodb2/table.py

내가 시도 :

def getByAdvertiser(adv): 
    matchingTable=swfTable.scan(advertiser__eq=adv) 
    return getTableElements(matchingTable) 
def getTableElements(table): 
    res=[] 
    for t in table: 
     res.append(t) 
    return res 
BOTO 테이블의 스캔 기능에 동의하는 것 http://boto.readthedocs.org/en/latest/ref/dynamodb2.html

swfTable이 유효한 테이블 인 경우 위 구문을 기반으로해야하며 .scan()은 요소를 반환하며 "광고주"는 발전기입니다 adv "(itunes.apple.com)과 같은"광고주 "에 적어도 하나의 요소가 있습니다. 그러나 다음과 같은 오류가 발생합니다.

Traceback (most recent call last): File "/Users/tai/Documents/workspace/testSelenium/testS/init.py", line 101, in forInFile() File "/Users/tai/Documents/workspace/testSelenium/testS/init.py", line 95, in forInFile dynamoAccess.getByAdvertiser("itunes.apple.com") File "/Users/tai/Documents/workspace/testSelenium/testS/dynamoAccess.py", line 34, in getByAdvertiser matchingTable=swfTable.scan(advertiser__eq=adv) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/boto/dynamodb/table.py", line 518, in scan return self.layer2.scan(self, *args, **kw) TypeError: scan() got an unexpected keyword argument 'advertiser__eq'

문서의 구문을 따르지 않는 것으로 나타났습니다.

results = self.table.scan(scan_filter={'asset': dynamodb.condition.EQ(asset)}) 

에서 :

Trouble getting a dynamodb scan to work with boto

또는 :

all_query = table.scan(attributes_to_get=['something']) 

에서 : boto python dynamodb scan attributes_to_get

내가 다른 BOTO DynamoDB의 질문을 볼 때

그러나 그들은 같은 구문을 사용합니다

내가 사용하고있는 것 또는 내가 본 모든 것을 문서화 한 것처럼 보이지 않습니다.

편집 : 나는 문제가 I이이 dynamodb2를 사용하여 해결할 것 대신에 2

aws_dynamo_table="decompiled_swf_text" 
conn= S3Connection(aws_access_key_id,aws_secret_access_key); 
dynamoConn = boto.connect_dynamodb(aws_access_key_id, aws_secret_access_key) 
dTable = dynamoConn.get_table(aws_dynamo_table) 

의 dynamodb1을 사용하고 있다고 할 수있다 생각

? 그렇다면 어떻게 설정해야합니까? 나는 노력하고있다 :

그러나 나는 어떻게 테이블을 쿼리하고 스캔 할 수 있는지 알지 못한다 ... 나는 사용할 수있는 기능이 없다.

답변

1

두 가지 예는 모두 traditional/low-level API입니다. 예를 들어 이전 API에서 scan 함수는 scanFilter를 매개 변수로 사용합니다.

및 구문

>>> results = users.scan(
...  age__in=[25, 26, 27, 28, 29], 
...  limit=1 
...) 

new/high level API 정의된다.

확실히 DynamoDB2로 전환해야합니다.당신의 오류 출력

in scan return self.layer2.scan(self, *args, **kw) TypeError: 

에서 당신이 DynamoDB의를 사용하는 대신 DynamoDB2의 layer2 API가 DynamoDB의 API를 정의하고 DynamoDB2에서 사라질 때문이었다 보인다.

그래서 table.scan 사용) BOTO DynamoDB2

1) get your table

2 스위치 (age__in = [25, 26, 27, 28, 29], 제한 = 1) 참조 here

관련 문제