15 분 간격으로 웹 사이트를 구문 분석하는 GAE (Google 앱 엔진) 앱이 있습니다. 매 15 분마다 cron은 가장 오래된 데이터 (이 경우 BitData()
)의 타임 스탬프를 검사하고 utc.now()
까지 해당 지점의 데이터를 구문 분석합니다. Unfortionetly 최신 BitData()
개체에 대한 NDB 데이터베이스 쿼리의 첫 번째 부분을 지나갈 수 없습니다.cronjob에서 NDB 쿼리 수행
코드 예제 : 제공
TypeError: order() expects a Property or query Order; received <class 'google.appengine.ext.ndb.model.DateTimeProperty'>
대신 순서에게 응답을 반대로 q = q.order(-BitData.tsamp)
를 사용 : 나는했습니다
TypeError: bad operand type for unary -: 'type'
을
def bitcoincharts_last():
q = BitData.query()
q = q.order(BitData.tstamp)
if q == None:
return '0'
else:
return q[0]
이 로그에 오류를 끈다 내 코드를 예제와 비교하여 확인했습니다. here, here, d NDB Google 문서 도구를 사용하지만 쿼리가 실행되지 않는 이유를 찾을 수 있습니다.
BitData :
class BitData(ndb.Model):
key = ndb.KeyProperty
tstamp = ndb.DateTimeProperty
price = ndb.IntegerProperty
amount = ndb.IntegerProperty
BitData 모델의 정의는 무엇입니까? –
이 질문을 업데이트했습니다. – Davidrd91