How to get cursor from mqlread() when using Freebase API?

前端 未结 2 580
逝去的感伤
逝去的感伤 2021-01-16 14:54

I\'m using the Python-Freebase module\'s mqlread(). Using the following query:

query = [{
  \"cursor\": True,
  \"id\":     None,
  \"type\":   \"/games/gam         


        
相关标签:
2条回答
  • 2021-01-16 15:41

    Support for MQL envelope parameters was dropped, presumably accidentally, in the 1.0.8 release of the Freebase Python library.

    If not don't need MQL extensions, you can just drop the parameter extended=True parameter and use mqlreaditer(query).

    If you need MQL extensions (or other envelope parameters), you'll have to fall back to 1.0.6 until someone fixes the problem and does a new release.

     sudo easy_install freebase==1.0.6
    
    0 讨论(0)
  • 2021-01-16 15:46

    I found that the Freebase-Python module actually includes a method that takes care of cursoring for you. Just call mqlreaditer(query, extended=true), and that will return a Python generator that you can iterate through. Behind the scenes the Freebase module will query and keep track of the cursor, return results on demand until a "false" cursor is reached.

    Very simple!

    0 讨论(0)
提交回复
热议问题