Making SPARQL queries to Wikidata using Python

Published: Jun 11, 2022 by Steve Baskauf

I recently solved several annoying problems that I’d been having when using SPARQL queries to acquire data from Wikidata. My success inspired me to write a comprehensive Python class that will reliably carry out every kind of SPARQL Query and Update, with defaults to easily make SELECT queries to Wikidata.

To read the post, visit this link.

You can access the code from this file at GitHub

Share

Latest Posts

Uploading a thousand Gallery images to Commons
Uploading a thousand Gallery images to Commons

I recently finished work on CommonsTool, a Python script to upload artwork images to Wikimedia Commons. In addition to uploading the image files, it creates Structured Data on Commons claims to provide machine-readable metadata about the images and to link them to Wikidata items that describe the underlying artwork objects. It also uploads the images to the Vanderbilt Libraries’ International Image Interoperability Framework (IIIF) server and generates IIIF manifests to display those images in a IIIF viewer.

Making SPARQL queries to Wikidata using Python
Making SPARQL queries to Wikidata using Python

I recently solved several annoying problems that I’d been having when using SPARQL queries to acquire data from Wikidata. My success inspired me to write a comprehensive Python class that will reliably carry out every kind of SPARQL Query and Update, with defaults to easily make SELECT queries to Wikidata.

Birding in Puerto Rico
Birding in Puerto Rico

After recently making a trip to Puerto Rico that was primarily focused on bird watching, I decided to write a blog post to pass on some of what we learned. Much of the information that we got from books or the Internet was outdated or incorrect, so hopefully this post will help others to have an easier time finding good places to bird there.