Querying DBpedia from Python How can I get information about an entity from DBpedia using Python?

Eg: I need to get all DBpedia information about USA.  So I need to write the query from python (SPARQL) and need to get all attributes on USA as result.

I tried :

PREFIX db: &lt;http://dbpedia.org/resource/&gt;
SELECT ?p ?o
WHERE { db:United_States ?p ?o }


But here all DBpedia information is not displaying.

How can I do this and which all are the possible plugins/api available for python to connect with DBpedia ?

Also what will be the SPARQL query for generating the above problem result?
You do not need a wrapper for DBPedia, you need a library that can issue a SPARQL query to its SPARQL endpoint.  Here is an option for the library and here is the URL to point it to: http://dbpedia.org/sparql

You need to issue a DESCRIBE query on the United_States resource page:

PREFIX dbres: &lt;http://dbpedia.org/resource/&gt;

DESCRIBE dbres:United_States


Please note this is a huge download of resulting triplets.

Here is how you would issue the query:



from SPARQLWrapper import SPARQLWrapper, JSON

def get_country_description():
    sparql = SPARQLWrapper("http://dbpedia.org/sparql")
    sparql.setReturnFormat(JSON)

    sparql.setQuery(query)  # the previous query as a literal string

    return sparql.query().convert()