@decentral1se: "watch out for that SimpleDatabase, there are some secret bugs! you always need to run _dumps() when you want to be sure to save because of an obsure behaviour in python"
@decentral1se: "watch out for that SimpleDatabase, there are some secret bugs! you always need to run _dumps() when you want to be sure to save because of an obsure behaviour in python"
An example of having some logic which always force a _dumps() call is here fa80d094a7/xbotlib.py (L559). I think if you have a db = SimpleDatabase() and then you do db['a'] = [] and then db['a'].append(1) then the .append doesn't trigger a _dumps() call. You have to do it yourself.
An example of having some logic which always force a `_dumps()` call is here https://git.vvvvvvaria.org/decentral1se/xbotlib/src/commit/fa80d094a7ed13b3cb210dcb227116d571326a7e/xbotlib.py#L559. I think if you have a `db = SimpleDatabase()` and then you do `db['a'] = []` and then `db['a'].append(1)` then the `.append` doesn't trigger a `_dumps()` call. You have to do it yourself.
You can use a https://docs.python.org/3/library/shelve.html instead which won't give you issues but then you miss out how easy it is to read the local JSON file.
Hope that makes sense!
@decentral1se: "watch out for that SimpleDatabase, there are some secret bugs! you always need to run _dumps() when you want to be sure to save because of an obsure behaviour in python"
An example of having some logic which always force a
_dumps()
call is herefa80d094a7/xbotlib.py (L559)
. I think if you have adb = SimpleDatabase()
and then you dodb['a'] = []
and thendb['a'].append(1)
then the.append
doesn't trigger a_dumps()
call. You have to do it yourself.You can use a https://docs.python.org/3/library/shelve.html instead which won't give you issues but then you miss out how easy it is to read the local JSON file.
Hope that makes sense!