Question

I had an script to read Freebase data, but it suddenly stop working. It outputs the following error:

AttributeError: 'Resource' object has no attribute 'mqlread'

So I tried the example code in the Google documentation,

from apiclient import discovery
from apiclient import model
import json

DEVELOPER_KEY = 'my_key'

model.JsonModel.alt_param = ""
freebase = discovery.build('freebase', 'v1', developerKey=DEVELOPER_KEY)
query = [{'id': None, 'name': None, 'type': '/film/film'}]

def do_query(cursor=""):

    response = json.loads(freebase.mqlread(query=json.dumps(query), cursor=cursor).execute())
    for item in response['result']:
        print item['name']

    return response.get("cursor")

cursor = do_query()
while(cursor):
    cursor = do_query(cursor)

And I get the same error... The mqlread method had dissapeared, also when I do a dir(freebase)I get this:

['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_add_basic_methods', '_add_nested_resources', '_add_next_methods', '_baseUrl', '_developerKey', '_dynamic_attrs', '_http', '_model', '_requestBuilder', '_resourceDesc', '_rootDesc', '_schema', '_set_dynamic_attr', '_set_service_methods', u'reconcile', u'search', u'search_media']

Have they removed this feature in the new version of the API client? I'm using version 1.2 of google-api-python-client

Was it helpful?

Solution

Sorry about that. This is a temporary issue with mqlread service not being visible from the Google API Discovery service. The API itself is still accessible from https://www.googleapis.com/freebase/v1/mqlread but google client library depends on the discovery service to expose mqlread as a method. Our engineering team is working on a fix and should have something rolled out shortly. I'll update this when they do.

OTHER TIPS

It seems that mql-related APIs are the old APIs and are not well supported by Google. So I would suggest you to use freebase.search() instead, which can finish almost all the things that freebase.mqlread() can do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top