This page brings together the exhibition-level record and the list of artworks associated with the exhibition. It is built from the workflows in notebooks/01-exhibition.ipynb and notebooks/02-artworks.ipynb.
2. Artworks in the exhibition
The artwork list is generated from the exhibition relation to the works in the exhibition.
from urllib.parse import urlencode
from urllib.request import Request, urlopen
import json
from html import escape
from IPython.display import HTML, display
exhibition_id = "Q141747732"
query = f"""
SELECT ?artwork ?artworkLabel WHERE {{
?artwork wdt:P31 wd:Q838948 ;
wdt:P608 wd:{exhibition_id} .
SERVICE wikibase:label {{ bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }}
}}
LIMIT 100
"""
endpoint = "https://query.wikidata.org/sparql"
params = urlencode({"query": query, "format": "json"})
url = f"{endpoint}?{params}"
request = Request(
url,
headers={
"Accept": "application/sparql-results+json",
"User-Agent": "loe-posit-notebook/1.0 (contact: simon.worthington@tib.eu)",
},
)
with urlopen(request, timeout=60) as response:
data = json.loads(response.read().decode("utf-8"))
rows = []
for b in data["results"]["bindings"]:
rows.append(
{
"artwork_id": b["artwork"]["value"].rsplit("/", 1)[-1],
"artwork": b.get("artworkLabel", {}).get("value", b["artwork"]["value"]),
}
)
if rows:
headers = ["artwork_id", "artwork"]
table = [
"<table class=\"table table-sm table-striped table-hover\" border=\"0\"><thead><tr>",
*[f"<th>{escape(h)}</th>" for h in headers],
"</tr></thead><tbody>",
]
for row in rows:
table.append(
"<tr>" + "".join(f"<td>{escape(str(row.get(h, '')))}</td>" for h in headers) + "</tr>"
)
table.append("</tbody></table>")
display(HTML("".join(table)))
else:
print("No artworks were found for this exhibition.")
| Q141749370 |
Duck Pond Bar, National City, California |
| Q141757299 |
The Former Site Of Duck Pond Bar, 3003 National City Blvd., National City California |
| Q141777045 |
Wallpaper: Rooms With Windows |
| Q141777055 |
Hands/Feet |
| Q141777058 |
Three Active Persons / With Standing Person |
| Q141777067 |
Pretzel And Ear |