title: How to solve error in passing variables to SQL query
body: <p>I have a list of existing tables in database, I need to update existing tables with csv files...
  So what I have done is...</p>
  <ol>
  <li><p>I have created temp tables in database and I have inserted the values from csv files to the temp tables in database.</p>
  </li>
  <li><p>then I have made two lists, one list consists of existing tables and other list consists of temp table.</p>
  </li>
  <li><p>I created my temp tables with prefixed existing tables names ending with temp eg. tablenametemp, so that I can match with existing tables.</p>
  </li>
  <li><p>once i found the match then I will update the existing tables with the temp tables with matching primary keys.</p>
  </li>
  <li><p>if the primary key already exists the I will update the existing records ELSE I will insert it as a new record to the table</p>
  </li>
  <li><p>once all done temp tables are removed
  here is the code which I have done..</p>
  <p>for a in list_table:
  if a+'temp' in list_temp:</p>
  <pre><code>     pk = engine.execute('''
                                   SELECT C.COLUMN_NAME 
                                   FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS T  
                                   JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE C ON C.CONSTRAINT_NAME = T.CONSTRAINT_NAME  
                                   WHERE C.TABLE_NAME = ? 
                                   AND T.CONSTRAINT_TYPE = 'PRIMARY KEY'  ''',a)
  
       pk_temp = engine.execute('''
                                   SELECT C.COLUMN_NAME 
                                   FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS T  
                                   JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE C ON C.CONSTRAINT_NAME = T.CONSTRAINT_NAME  
                                   WHERE C.TABLE_NAME = ? 
                                   AND T.CONSTRAINT_TYPE = 'PRIMARY KEY'  ''',a+&quot;temp&quot;)
  
       col = engine.execute('''
                                   SELECT column_name FROM INFORMATION_SCHEMA. COLUMNS
                                   WHERE TABLE_NAME = ?  ''',a)
       col_temp = engine.execute('''
                                   SELECT column_name FROM INFORMATION_SCHEMA. COLUMNS
                                   WHERE TABLE_NAME = ?  ''',a+&quot;temp&quot;)
  
       sql_merge = engine.execute(&quot;&quot;&quot;
       MERGE %s Target
       USING %s AS Source
       ON Source.%s = Target.%s
       /* new records ('right match') */
       WHEN NOT MATCHED BY Target THEN
       INSERT (%s)
       VALUES (Source.%s)
       /* matching records ('inner match') */
       WHEN MATCHED THEN
       UPDATE SET
       Target.%s = Source.%s
       /* deprecated records ('left match') */
       WHEN NOT MATCHED BY Source THEN
       DELETE
       ;
       &quot;&quot;&quot;, (a, a + &quot;temp&quot;, pk, pk_temp, col, col_temp, col, col_temp))
  
       engine.execute(&quot;&quot;&quot;DROP TABLE IF EXISTS ? &quot;&quot;&quot;, a + &quot;temp&quot;)
  </code></pre>
  </li>
  </ol>
  <p>when I execute this code I got the error like this</p>
  <p>**
  'The SQL contains 0 parameter markers, but 8 parameters were supplied', 'HY000'
  **</p>
  <p>I think this error is thrown when I execute the sql_merge query, and I really got no idea of how to solve this, Please help me</p>