[Developers] Python query not working?
Chris Mahon
darthmahon at gmail.com
Tue Jul 22 14:32:47 UTC 2008
Right gotcha, makes sense now :)
Out of interest, does the query on the link I provided limit the amount of
results it will return or does it return everything?
On Tue, Jul 22, 2008 at 3:26 PM, Christopher R. Maden <crism at metaweb.com>
wrote:
> Chris Mahon wrote:
> > Right ok, so do I still put the {} brackets before and after or do I
> > simple do this?
> >
> > query = [...query here...]
>
> Short answer is to do what you show: query = [...]
>
> However, it's important to note that the square brackets don't
> *surround* the query; they are *part of* the query.
>
> The important part in freebase-python is the call to mqlread().
>
> If you are looking for a single object:
>
> result = mss.mqlread( { constraints } )
>
> If you are looking for multiple objects:
>
> results = mss.mqlread( [ { constraints } ] )
>
> E.g.:
>
> sting = mss.mqlread( { "type" : "/music/artist",
> "name" : "Sting",
> "id" : None } )
>
> smiths = mss.mqlread( [ { "type" : "/music/artist",
> "name" : "Robert Smith",
> "id" : None } ] )
>
> [As a note, it is generally a bad idea to assume that a name-based query
> is going to have a single result, as the freebase-python sample, and my
> Sting example above, do. If a Freebase user adds another instance of
> the same name, all your code will break. Unless your query is
> ID-constrained, you are better off looking for multiple results all the
> time.]
>
> ~Chris
> --
> Christopher R. Maden
> Data Architect
> Freebase.com: <URL: http://www.freebase.com/ >
> Metaweb Technologes, Inc. <URL: http://www.metaweb.com/ >
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20080722/f3b91e29/attachment.htm
More information about the Developers
mailing list