Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not an Issue : regarding documentation on using Wikidata #14

Open
sobalgi opened this issue Nov 18, 2018 · 2 comments
Open

Not an Issue : regarding documentation on using Wikidata #14

sobalgi opened this issue Nov 18, 2018 · 2 comments

Comments

@sobalgi
Copy link

sobalgi commented Nov 18, 2018

Hello,
Firstly this is not an issue with the code. Sorry for posting this under issues.

I wanted to get some additional documentation on using the module.

Suppose I want get a list of all the entities with a certain property.
The current documentation Wikidata client library for Python only shows how to get a property given an entity.
I'm trying to find if I can get a list of entities with the mentioned property.

e.g. get a list of countries (entities) given the property for country 'P17'.

I'm not sure if this already exists. Please let me know if it exists.
I would appreciate if the module had an improved documentation Issue #10 .

Thanks,
@sobalgi.

@bfontaine
Copy link

You can do that with SPARQL queries. You can play with your query on https://query.wikidata.org then use pywikibot to run it in Python.

from pywikibot.data.sparql import SparqlQuery

q = SparqlQuery("SELECT ...")
for item in q:
    # do something
    ...

I don’t know if the wikidata module allows you to do that.

@danmichaelo
Copy link

You can do that with SPARQL queries. You can play with your query on https://query.wikidata.org then use pywikibot to run it in Python.

from pywikibot.data.sparql import SparqlQuery

q = SparqlQuery("SELECT ...")
for item in q:
    # do something
    ...

I don’t know if the wikidata module allows you to do that.

Updated pywikibot syntax for the anyone googling this:

from pywikibot.data.sparql import SparqlQuery

query = SparqlQuery()
for item in query.select("SELECT ..."):
    # do something
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants