Find record in dataset using dictionary

I am using dataset in python to create databases and queries. To create a record, you need dictionaries:

entry1={}; entry[id]=1;entry[name]='a'
DBd['data'].insert(entry1)

      

I would like to make sure that I am not entering the entry if it already exists. The find method, however, does not use dictionaries, but will work like this:

DB['data'].find(id=1,name='a')

      

is there any way i could do something like

DB['data'].find(entry1)

      

i.e. I would need to convert the dictionary to a valid filter.

+3


source to share


1 answer


You can include a dictionary in parameters using parameters **kwargs

, for example:



DB['data'].find(**entry1)

      

+4


source







All Articles