我有一個GAE(谷歌應用程序引擎)應用程序,它以15分鐘的時間間隔解析一個網站。每隔15分鐘cron將檢查最舊數據的時間戳(在這種情況下爲BitData()
),並將解析來自該點的數據,直到utc.now()
。 不幸的是,我無法通過查詢NDB數據庫的最新BitData()
對象的第一部分。在cronjob中執行NDB查詢
代碼示例:
def bitcoincharts_last():
q = BitData.query()
q = q.order(BitData.tstamp)
if q == None:
return '0'
else:
return q[0]
該拿出一個錯誤日誌中:
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'
我已經用示例here,here檢查我的代碼, d NDB谷歌文檔,但我似乎無法找到爲什麼查詢不會運行。
BitData:
class BitData(ndb.Model):
key = ndb.KeyProperty
tstamp = ndb.DateTimeProperty
price = ndb.IntegerProperty
amount = ndb.IntegerProperty
什麼是你的BitData模型的定義? – 2013-04-08 04:10:27
更新了問題。 – Davidrd91 2013-04-08 04:35:25