Wednesday, October 3, 2012

MySQL statements in Python to join 'where'




where = [
    ('license_size', '6'),
    ('extref', 'CA4B8EC17B8F3833E04400144F3A7847'),
    ('asdf', 'qwer')
        ]

str_where_begin = " WHERE "
lst_where = []
for tup in where:
    lst_where.append("%s = '%s'" % tup)
str_where = " AND ".join(lst_where)

str_fragment_where = str_where_begin + str_where

print str_fragment_where










No comments:

Post a Comment