SuLab / WikidataIntegrator

A Wikidata Python module integrating the MediaWiki API and the Wikidata SPARQL endpoint
MIT License
244 stars 46 forks source link

CRUD Operations #194

Closed versant2612 closed 2 years ago

versant2612 commented 2 years ago

Are there Create, Read, Update and Delete methods for PNodes and Qnodes?

versant2612 commented 2 years ago

How can I set the alternative labels of an Item?

andrawaag commented 2 years ago

Regarding CRUD, yes there are methods. Getting an item (aka Qnode) you can get the following line item = wdi_core.WDItemEngine(wd_item_id=Qxx)

Creating a new item is done by the following line item = wdi_core.WDItemEngine(new_item=True)

adding statements is done by adding the data parameter to above snippets, where the data is a list of statements eg. statements = [] statements.add(wdi_core.WDItemID(value="Qxx", prop_nr = "Pyy") statements.add(wdi_core.WDString(value="Just a text", prop_nr="Pzz") item = wdi_core.WDItemEngine(wd_item_id="Qaa", data=statements)

etc.

versant2612 commented 2 years ago

@andrawaag thank you. How can I delete an item or a property?

Is it possible to change a property data type without delete and recreate?

andrawaag commented 2 years ago

@versant2612 I think that that is possible on Wikibase, but on Wikidata both deletions of an item or property needs to be requested.

Not it is not possible to change a property data type without deleting and recreating it. It also would be complicated since how to deal with the already entered values. If this would be possible it would bring a property with basically two data types