Depending on your operating system, there is a limit to how many open connections can be held on the database file. It looks like you are hitting this limit.
If I understand your goal correctly, use of the
search_molecule() method might be a better approach. Assuming that your molecules are stored in a list named
for i in molecules:
ss = SimilaritySearch(i)
for j in molecules:
hit = ss.search_molecule(j)
I don't believe this will cause the problem you see as it never access the database.
Does that resolve your issue?