gqlquery with_cursorが機能していません
-
30-09-2019 - |
質問
GQLqueryでカーソルを使用することが適切に機能していないように見える理由を誰かが知っているかどうか疑問に思う。
私は次のことを実行しています。
query = "SELECT * FROM myTable WHERE accountId = 'agdwMnBtZXNochALEglTTkFjY291bnQYpQEM' and lastUpdated > DATETIME('0001-01-01 00:00:00') ORDER BY lastUpdated ASC LIMIT 100"
if lastCursor:
dataLookup = GqlQuery(query).with_cursor(lastCursor)
else
dataLookup = GqlQuery(query)
//dataLookup.count() here returns some value like 350
for dataItem in dataLookup:
... do processing ...
myCursor = dataLookup.cursor()
dataLookup2 = GqlQuery(query).with_cursor(myCursor)
//dataLookup2.count() now returns 0, even though previously it indicates many more batches can be returned
ご協力ありがとうございます。
解決
クエリで制限を使用しないでください。最初の100の結果のみを返し、すべてが必要だと思いますが、毎回100のバッチで処理します。
これが私がすることです(あなたの例コードに基づいて):
query = GqlQuery("SELECT * FROM myTable WHERE accountId =
'agdwMnBtZXNochALEglTTkFjY291bnQYpQEM' and
lastUpdated > DATETIME('0001-01-01 00:00:00') ORDER BY lastUpdated ASC")
dataLookup = query.fetch(100) # get first 100 results
for dataItem in dataLookup:
# do processing
myCursor = query.cursor() # returns last entry of previous fetch
if myCursor:
# get next 100 results
dataLookup2 = query.with_cursor(myCursor).fetch(100)
所属していません StackOverflow