title: How to use Executemany in my situation?
body: <p>How can I get these sequence of SQL statements? to work? I have previously only dealt with single <code>select</code> statements and <code>cursor.execute</code> worked fine for that. I'm not sure what to do in this case now. The error I am getting is <code>format requires a mapping</code></p>
  
  <pre><code>args =  {
          "timepattern" : timepattern,
          "datestart_int" : datestart_int,
          "dateend_int" : dateend_int
          }
  sql = ( "CREATE TEMPORARY TABLE cohort_users (user_id INTEGER);                                "
              "INSERT INTO cohort_users (user_id)                                                    "
              "SELECT id FROM users WHERE registered_at BETWEEN %(datestart_int)s AND %(dateend_int)s;                        "
              "SELECT 1, FROM_UNIXTIME(%(dateend_int)s, %(timepattern)s)                                                    "
              "UNION ALL                                                                            "
              "SELECT (COUNT(DISTINCT x.user_id)/(SELECT COUNT(1) FROM cohort_users)),             "
              "        FROM_UNIXTIME((%(dateend_int)s + (7 * 24 * 60 * 60)), %(timepattern)s)                                "
              "FROM cohort_users z INNER JOIN actions x ON x.user_id = z.id                        "
              "WHERE x.did_at BETWEEN (%(datestart_int)s + (7 * 24 * 60 * 60)) AND (%(dateend_int)s + (7 * 24 * 60 * 60))        "
              "DROP TABLE cohort_users;                                                            "
              )
  
  cursor.executemany(sql,args)
  </code></pre>