有没有办法增加 tinydb JSON 限制?
Is there a way to increase tinydb JSON limit?
我有一个 tinydb json 文件,但我注意到在某个时候它拒绝向 json 文件写入更多项目并在解析时抛出错误,因为它在中间被切断写一个项目
这是回溯。它显示 json 解析器无法解析,因为编写器在项目中间中断了写入
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "main.py", line 79, in run
message.process()
File "C:\Users\Administrator\Downloads\dbtest\Login_Message.py", line 45, in process
DataBase.loadAccount(self)
File "C:\Users\Administrator\Downloads\dbtest\DataBase.py", line 9, in loadAccount
user_data = db.search(query.token == str(user.token))
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 234, in search
docs = [doc for doc in self if cond(doc)]
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 234, in <listcomp>
docs = [doc for doc in self if cond(doc)]
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 588, in __iter__
for doc_id, doc in self._read_table().items():
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 638, in _read_table
tables = self._storage.read()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\storages.py", line 125, in read
return json.load(self._handle)
File "C:\Program Files (x86)\Python38-32\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
File "C:\Program Files (x86)\Python38-32\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Program Files (x86)\Python38-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files (x86)\Python38-32\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 234357 (char 234356)
发生这种情况的原因是因为多个线程同时写入 db 文件所以我最终手动写入多个文件:每个条目一个
我有一个 tinydb json 文件,但我注意到在某个时候它拒绝向 json 文件写入更多项目并在解析时抛出错误,因为它在中间被切断写一个项目
这是回溯。它显示 json 解析器无法解析,因为编写器在项目中间中断了写入
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "main.py", line 79, in run
message.process()
File "C:\Users\Administrator\Downloads\dbtest\Login_Message.py", line 45, in process
DataBase.loadAccount(self)
File "C:\Users\Administrator\Downloads\dbtest\DataBase.py", line 9, in loadAccount
user_data = db.search(query.token == str(user.token))
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 234, in search
docs = [doc for doc in self if cond(doc)]
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 234, in <listcomp>
docs = [doc for doc in self if cond(doc)]
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 588, in __iter__
for doc_id, doc in self._read_table().items():
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 638, in _read_table
tables = self._storage.read()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\storages.py", line 125, in read
return json.load(self._handle)
File "C:\Program Files (x86)\Python38-32\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
File "C:\Program Files (x86)\Python38-32\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Program Files (x86)\Python38-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files (x86)\Python38-32\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 234357 (char 234356)
发生这种情况的原因是因为多个线程同时写入 db 文件所以我最终手动写入多个文件:每个条目一个