I use dataset in python to create and query databases. It takes dictionaries to create an entry:
entry1={}; entry[id]=1;entry[name]='a'
DBd['data'].insert(entry1)
I would like to make sure that I do not enter the entry if it already exists. However, the find method doesn't take dictionaries, but would work as follows:
DB['data'].find(id=1,name='a')
is there some way that I could do something like
DB['data'].find(entry1)
i.e. I would need to convert the dictionary into a valid filter.
You can turn a dictionary into parameters using **kwargs parameters like this:
DB['data'].find(**entry1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With