Converting a dictionary map to a mysql query

Viewed 22

I have a dictionary:

queryParameters = {
    "email":None,
    "party_type":'BUYER',
    "mobile":'9953610508'
}

I need to convert this into a sql where query excluding the None values. For this dict it would be something like this

select id from tff_party where deleted_at is null and mobile=9953610508 and party_type='BUYER';

I have created a function but string concatenation seems a problem here.

for key in queryParameters.keys():
    if queryParameters[key] is not None:
        res = key + "=" + queryParameters[key]
0 Answers
Related