Describe the bug
PermissionError: [Errno 13] Permission denied: 'filename.json' is thrown when a large number of items are inserted by the for loop. Many elements output the obscure "utf-8" string but appear in the file. A file access error occurs on some item. I called this several times and each time I got an error on inserting a different element. Therefore, I am sure that this is a critical bug related to filelock.
Code:
second = """20053197
359237977
... some data (100+ strings)
736041598
610442490""".split("\n")
for e in second:
print(e)
SUBSCRIPTIONS.add({"vkid": int(e)})
Output:
...
utf-8
747262594
utf-8
285519977
utf-8
696637496
utf-8
659376205
Traceback (most recent call last):
File "c:\Users\Mark\Desktop\vkg\vkgid.py", line 236, in <module>
SUBSCRIPTIONS.add({"vkid": int(e)})
File "C:\Users\Mark\AppData\Local\Programs\Python\Python311\Lib\site-packages\pysondb\db.py", line 91, in add
with open(self.filename, "r+", encoding='utf-8') as db_file:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'subscriptions.json'
I also find it strange to output "utf-8" everywhere. It's like when something throws a KeyError, you catch it and output like in this example:
a = {"foo": None} # some test dict
try:
print(a["bar"])
except Exception as e:
print(e)
# returns "bar"
How to reproduce
Use Windows 10 and pysondb==1.6.7 (the latest?)
Describe the bug
PermissionError: [Errno 13] Permission denied: 'filename.json' is thrown when a large number of items are inserted by the for loop. Many elements output the obscure "utf-8" string but appear in the file. A file access error occurs on some item. I called this several times and each time I got an error on inserting a different element. Therefore, I am sure that this is a critical bug related to filelock.
Code:
Output:
I also find it strange to output "utf-8" everywhere. It's like when something throws a KeyError, you catch it and output like in this example:
How to reproduce
Use Windows 10 and pysondb==1.6.7 (the latest?)