I run the code using the shelve module. I expect to get 3 files as a database: .dir, .dat and .bak. Instead, I have a file with the .db extension. I can't read the created database.
I work on the manaconda environment on a apple m1 chip, rdkit 2022.03.5, python == 3.9.13.
If someone has encountered a similar problem, what could be the reason that shelve creates a database with the .db extension?
I ran the next simplest code:
import shelve
db = shelve.open('dbs/test', flag='c', protocol=4)
db['a'] = 'A'
db.close()
And the output file is: dbs/test.db
The problem starts when I am working with the created db. For example, with the simplest database (test.db) I can extract the keys by doing next:
db = shelve.open('dbs/test', flag='r', protocol=4)
names = db.keys()
print(tuple(names))
BUT but the same code run on a bigger database (with the strange for shelve .db extension) that I use for work, next error message appears:
SystemError Traceback (most recent call last)
Cell In [48], line 1
----> 1 tuple(names)
File ~/miniconda3/envs/rd22/lib/python3.9/_collections_abc.py:826, in KeysView.__iter__(self)
825 def __iter__(self):
--> 826 yield from self._mapping
File ~/miniconda3/envs/rd22/lib/python3.9/shelve.py:95, in Shelf.__iter__(self)
94 def __iter__(self):
---> 95 for k in self.dict.keys():
96 yield k.decode(self.keyencoding)
SystemError: Negative size passed to PyBytes_FromStringAndSize
I did not have any similar problems when I worked with the usual DBM database format