0

actual version of tinydb 4.3.0

from tinydb import TinyDB, Query
db = TinyDB('db.json')
    dbtable = db.table('Counters')
    Search = Query()
    splitemsg = ['', 'nwm', '', 'nwm', '', 'nwm', ''] #in other cases it can be different
for tableval in dbtable.all():
    for i in splitemsg:
       if i == counterfilt:
          dbtable.update({'Value': tableval['Value'] + 1}, Search['Counter_filter'].any(counterfilt)) #this will add 1 to the Value in the table

my json file row:

{"_default": {}, "Counters": {"1": {"Counter_name": "nwm", "Counter_filter": ["nwm", "nvm"], "Value": 0}}}

After this it is supposed to add 3 to the value in my table in tinydb, but it just add 1, why it's not working? I tried some sleep inside loop, didn't work. I tried other versions of tinydb, didn't work. I would have another solution for this if I can split the string, but separator is variable and I need the separator to be keeped.

4

0 回答 0