我對App Engine的這條巨蟒代碼返回光標爲空字符串。爲什麼?光標取(),但不運行()在App Engine上
1
A
回答
3
run()
方法只是設置運行查詢(並在生產中,在後臺啓動RPC調用)所需的條件。爲了使您的查詢具有任何數據知識(遊標或其他),您需要通過耗盡查詢來獲取結果。
>>> query = Model.all()
>>> query_iterator = query.run(limit=5)
>>> query.cursor()
''
>>> list(query_iterator) # Exhaust iterator
[<db.Model instance at 0x...>, ...]
>>> query.cursor()
'E-ABAIICG2oMYXByaWdvbmluamE0cgsLEgVNb2RlbBgKDBQ='
1
Query.run()
(或簡單地迭代Query
的實例)返回迭代器。當你得到查詢的光標時,它甚至沒有開始提取任何東西。我想,在你的情況 - 當你要使用遊標 - fetch()
將會很好。
在你真正需要它的情況下,這應該做的伎倆:
def queryArticles(status=1, limit=10, **offset):
query = Article.all().filter('status =', status).order('-modified')
articles = query.run(limit=limit, batch_size=limit, **offset)
articles = articles.next()
cursor = query.cursor()
return articles, cursor
+0
謝謝伊戈爾! fetch()對我很有好處,因爲文章會轉到jinja輸出。但是因爲我喜歡理解我寫的東西,所以我對fetch()和run()之間的區別感興趣。 GAE文檔只說fetch()是run()的一個包裝器, – wombatonfire
相關問題
- 1. 在App上運行的Google App Engine PHP
- 2. 在App Engine上運行夾層
- 3. 在Google App Engine上運行Drools規則
- 4. 如何在Google App Engine上運行FuelPHP
- 5. 在Google App Engine上運行Boto
- 6. 在Google App Engine上運行Jaunt(網頁抓取工具):Java
- 7. App Engine,查詢結果在本地顯示,但不在App Engine上
- 8. 我可以在Google App Engine PHP運行時上運行CakePHP嗎?
- 9. 在App Engine上
- 10. 圖像在本地工作,但在Google App Engine上部署後無法運行?
- 11. 在Google App Engine包中運行測試?
- 12. Google App Engine NDB - 查詢本地開發但未在生產中的光標
- 13. 在Google App Engine上在本地運行Wordpress時出錯
- 14. 在1.5目標上運行2.3.3 APP
- 15. 在Google App Engine上運行時調用兩次Firebase函數
- 16. 在Google App Engine上運行的大型網站的示例
- 17. Java DrEdit無法在Google App Engine上運行
- 18. 在Google App Engine上運行SciPy的替代方案?
- 19. 是否可以在Google App Engine上運行Google Omaha?
- 20. 在多個客戶域上運行Google App Engine應用程序
- 21. 如何判斷代碼是否在Google App Engine上運行?
- 22. 如何在App Engine上運行的應用程序的免費
- 23. 在App Engine上定期運行一些java?
- 24. 在IntelliJ上配置Google App Engine Python運行時
- 25. 在Google App Engine上運行Wordpress時出現數據庫錯誤
- 26. 是否有人獲得Recaptcha在Google App Engine上運行(Java)?
- 27. 通過JRuby在Google App Engine上運行RSpec
- 28. 在Google App Engine上運行基於Django 1.4的應用程序
- 29. JavaFX 2.0是否在Google App Engine上運行?
- 30. 在Google App Engine上運行applet時遇到InvocationTargetException
謝謝tdavis! – wombatonfire
謝謝!救了我 –