Deleting/Destroying entities in the quadstore

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Deleting/Destroying entities in the quadstore

GoMa
Hello,

I like to destroy/delete a created individual via the destroy_entity() function.
It looks like destroy_entity() deletes/destroys the entity not completely in the quadstore.

For example I create an individual via individualA = onto.ClassA(), then I destroy it via owlready2.destroy_entity(individualA). Using onto.classes() shows that the individual (individualA with the name classa1) is deleted. If I now create again an individual via individualA = onto.ClassA() an individual with the name "classa2" is created. I expect that the name is classa1 not classa2, cause I destroyed classa1 in the previous step. Trying to rename the individualA via individualA.name = "classa1" leads to the following error message:

ERROR - log - write  : Traceback (most recent call last):
ERROR - log - write  :   File "PATH/playground.py", line 12, in <module>
ERROR - log - write  : individualA.name = 'classa1'
ERROR - log - write  :   File "PATH\Python37\lib\site-packages\owlready2\individual.py", line 254, in __setattr__
ERROR - log - write  : else:                         super().__setattr__(attr, value)
ERROR - log - write  :   File "PATH\Python37\lib\site-packages\owlready2\individual.py", line 57, in set_name
ERROR - log - write  : self.namespace.world._refactor(self.storid, "%s%s" % (self.namespace.base_iri, name))
ERROR - log - write  :   File "PATH\Python37\lib\site-packages\owlready2\triplelite.py", line 515, in _refactor_dict
ERROR - log - write  : self.execute("UPDATE resources SET iri=? WHERE storid=?", (new_iri, storid,))
ERROR - log - write  : sqlite3
ERROR - log - write  : .
ERROR - log - write  : IntegrityError
ERROR - log - write  : :
ERROR - log - write  : UNIQUE constraint failed: resources.iri

Code:
individualA = onto.ClassA()
owlready2.destroy_entity(individualA)
list(onto.classes())
individualA = onto.ClassA()
individualA.name = "classa1"

Is my assumption correct that destroy_entity should delete the entity in python as well as in the quadstore?
Is there a different way to delete/destroy an entity in the quadstore? I am not familiar with databases/SQLite.

Thanks for your support

GoMa
Reply | Threaded
Open this post in threaded view
|

Re: Deleting/Destroying entities in the quadstore

Jiba
Administrator
Hello,

You are right: the RDF triples were deleted by destroy_entity(), but not the IRI. The IRI was thus still used and registered.

I fixed the problem in the development version of Owlready on BitBucket.

Thank you for reporting this problem,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Deleting/Destroying entities in the quadstore

alexf
Hi, I still have got this problem. So, how to fix it?
Reply | Threaded
Open this post in threaded view
|

Re: Deleting/Destroying entities in the quadstore

Jiba
Administrator
Hello,

I tested it on simple example but all resources names were properly removed. On the contrary, I found that some RDF triples were not properly removed when dealing with class construct or equivalent to relations. I fixed it in the development version on Bitbucket.

If your problem persists, could you send me an example to reproduce the problem?

Jiba