piskvorky / sqlitedict

Persistent dict, backed by sqlite3 and pickle, multithread-safe.
Apache License 2.0
1.17k stars 131 forks source link

Cant update nested dictionaries #117

Closed gooseillo closed 4 years ago

gooseillo commented 4 years ago

example: mydict = SqliteDict('./my_db.sqlite', autocommit=True)

mydict[1] = {'test1':'xyz', 'test2':'asd'} mydict[2] = {'test1':'xyz', 'test2':'asd'} mydict[3] = {'test1':'xyz', 'test2':'asd'}

for i, j in mydict.items(): print(i, j)

Result: 1 {'test1': 'xyz', 'test2': 'asd'} 2 {'test1': 'xyz', 'test2': 'asd'} 3 {'test1': 'xyz', 'test2': 'asd'}

Now, If I try to update the first key with another key value pair - it does not update it

mydict[1]['test3'] = 'pqr'

Result: 1 {'test1': 'xyz', 'test2': 'asd'} 2 {'test1': 'xyz', 'test2': 'asd'} 3 {'test1': 'xyz', 'test2': 'asd'}

piskvorky commented 4 years ago

For storing objects that you later mutate in memory, see the Beware note in the documentation.