Using a separate (non-Wikidata) Wikibase instance

In this example, we have downloaded and run the wikibase docker images from here: https://github.com/wmde/wikibase-docker

Before running this example, I created an item on my local wikibase with the label "Greg"


In [8]:
from wikidataintegrator import wdi_core, wdi_login, wdi_helpers
from wikidataintegrator.wdi_core import WDItemEngine

In [9]:
# set urls
mediawiki_api_url = 'http://localhost:8181/w/api.php'
sparql_endpoint_url = 'http://localhost:8282/proxy/wdqs/bigdata/namespace/wdq/sparql'

In [10]:
# create a WDItemEngine class with the urls preset
LocalItemEngine = WDItemEngine.wikibase_item_engine_factory(mediawiki_api_url, sparql_endpoint_url)

In [13]:
# we can now retrieve this item from our local wikibase
litem = LocalItemEngine(wd_item_id="Q2")
litem.get_label()


Out[13]:
'Greg'

In [14]:
# and can also still access regular wikidata
item = WDItemEngine(wd_item_id="Q2")
item.get_label()


Out[14]:
'Earth'

In [17]:
# to login:
local_login = wdi_login.WDLogin("test", "password", mediawiki_api_url)


http://localhost:8181/w/api.php
Successfully logged in as Test