title: Filling up placeholders in string
body: <p>I have in mind a dynamic way of creating MySQL statement which has to be filled up with values passed from an outside function.</p>
  
  <pre><code>def check_id(table_name=None, *args):
  """"""
    args = args[0]
    # print args, type(args), len(args)
    vals = [ tuple(elem.values()) for elem in args ]
  
    if isinstance(args, list):
      columns = []
      for idx, key in enumerate(args[0].keys()):
        if idx == len(args[0].keys()):
          columns.append((key, "= '%s'"))
        columns.append((key, "= '%s', AND"))
  
      columns = ' '.join("`%s` %s" % x for x in columns)
     else:
       print "NOT A LIST"
    sql = """SELECT id FROM %(table_name)s
           WHERE %(columns)s;""" % {'table_name':table_name, 'columns':vals}
    print sql
  </code></pre>
  
  <p>columns would be created as follow:</p>
  
  <pre><code>`size` = '%s', AND `resource_group_id` = '%s', AND `description` = '%s', AND `name` = '%s', AND `created` = '%s', AND `url` = '%s', AND `format` = '%s', AND `res_geo_0` = '%s', AND `tracking_summary_total` = '%s', AND `revision_timestamp` = '%s', AND `res_geo_1` = '%s', AND `state` = '%s', AND `last_modified` = '%s', AND `webstore_last_updated` = '%s', AND `url_type` = '%s', AND `position` = '%s', AND `revision_id` = '%s', AND `webstore_url` = '%s', AND `resource_type` = '%s', AND `tracking_summary_recent` = '%s', AND
  </code></pre>
  
  <p>How would I fill up the the placeholders '%s' with values from vals. Any idea? Are those even treated as placeholder with python? or Is this a wrong approach?</p>