OperationalError: too many SQL variables

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

OperationalError: too many SQL variables

Chloé
Hello,

I dynamically construct an ontology from extracted information from few hundreds of documents. I obtain the following error:

--
  File "F:/Python36/workspace/txtstout21owl.py", line 765, in testPeuplementUniqueOnto
    for iprod in desc.instances():

  File "F:\Anaconda\lib\site-packages\owlready2\entity.py", line 365, in instances
    return Class.namespace.world.search(type = Class)

  File "F:\Anaconda\lib\site-packages\owlready2\namespace.py", line 216, in search
    r = self.graph.search(prop_vals)

  File "F:\Anaconda\lib\site-packages\owlready2\triplelite.py", line 475, in search
    return self.execute(req, params).fetchall()

 OperationalError: too many SQL variables
--

I can't catch the error with "except OperationalError:", because "NameError: name 'OperationalError' is not defined"
and no more with : "except owl.OperationalError:", because "AttributeError: module 'owlready2' has no attribute 'OperationalError'"

Could you help me to resolve the error or at least to catch the error to continue the process even I can't process all the documents ?

Thank you very much,

Chloé
Reply | Threaded
Open this post in threaded view
|

Re: OperationalError: too many SQL variables

Jiba
Administrator
Hello,

To catch the error, you need to import the error class from the sqlite3 module, as follows :

from sqlite3 import OperationalError


To solve the problem, I would need more information. Are you sure that Class is really a Class and not something else? Is it possible for me to reproduce the problem?

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: OperationalError: too many SQL variables

Chloé
Thank you very much for the answer.

My command is :

for desc in onto.Produit.descendants():
       for iprod in desc.instances():
               print(iprod.name)

"Produit" is a Class, and the descendants should be too, but there are many (about 1000).

I re-tried the execution and it works now!

Sorry for the inconvenience,

Chloé