piskvorky/sqlitedict

Add example how to delete a key/value pair

bluepuma77 opened this issue · 2 comments

Thanks for this great piece of software, it really makes dealing with key/value pairs and sqlite so much easier.

The documentation is good, I am just missing SELECT error handling and a DELETE example.

try:
    value = db[key]
except KeyError:
    print('Key not found', key)

What's the best way to DELETE a key/value pair from sqlite?

The easiest way to delete items is del db[key], as SqliteDict implements __delitem__:

https://github.com/RaRe-Technologies/sqlitedict/blob/f5c57f1f833e251b8ffe2e63642d4923b52646cd/sqlitedict.py#L257-L266

Perfect, thanks!