Skip to content

Instantly share code, notes, and snippets.

@willard1218
Created August 20, 2018 03:40
Show Gist options
  • Save willard1218/784d61fe3fdae1d66e4ad84dc2b9822a to your computer and use it in GitHub Desktop.
Save willard1218/784d61fe3fdae1d66e4ad84dc2b9822a to your computer and use it in GitHub Desktop.
dsfdsf
inputDict = {'Store_name': 'Los Angeles',
'Sales': '1500',
'XXX' :555}
whereConditions = []
for key, value in inputDict.items():
cond = "%s = '%s'" % (key, value)
whereConditions.append(cond)
whereConditionSql = ' AND '.join(whereConditions)
sql = 'select * from X where %s' % whereConditionSql
print(sql)
# "select * from X where Store_name = 'Los Angeles' AND Sales = '1500' AND XXX = '555'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment