mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement
Question: Following is my python script:

    
    
    #!/usr/bin/env python  
    
    import mysql.connector
    cnx = mysql.connector.connect(user='qdb1', password='qdb1', host='170.19.17.9', database='qdb1')
    cursor = cnx.cursor()
    
    insert_sql = ("insert into qdb1.amis"
                  " (CUSTOMER_NAME, AWS_ACCOUNT, AMI_START, CRT_REGION_PRIMARY, CRT_REGION_DR1, CRT_REGION_DR2, DBAPP_INST_ID, DBAPP_AMI_ID, DBAPP_AMI_NAME, VISTA_INST_ID, VISTA_AMI_ID, VISTA_AMI_NAME, WS_INST_ID, WS_AMI_ID, WS_AMI_NAME, DEL_REGION_PRIMARY, DEL_REGION_DR1, DEL_REGION_DR2, DELETED_AMI_PRIMARY, DELETED_SNAP_PRIMARY, DELETED_AMI_DR1, DELETED_SNAP_DR1, DELETED_AMI_DR2, DELETED_SNAP_DR2, SUCCESSFUL) "
                  "values ( %(CUSTOMER_NAME)s , %(AWS_ACCOUNT)s , %(AMI_START)s , %(CRT_REGION_PRIMARY)s , %(CRT_REGION_DR1)s , %(CRT_REGION_DR2)s , %(DBAPP_INST_ID)s , %(DBAPP_AMI_ID)s , %(DBAPP_AMI_NAME)s , %(VISTA_INST_ID)s , %(VISTA_AMI_ID)s , %(VISTA_AMI_NAME)s , %(WS_INST_ID)s , %(WS_AMI_ID)s , %(WS_AMI_NAME)s , %(DEL_REGION_PRIMARY)s , %(DEL_REGION_DR1)s , %(DEL_REGION_DR2)s , %(DELETED_AMI_PRIMARY)s , %(DELETED_SNAP_PRIMARY)s , %(DELETED_AMI_DR1)s , %(DELETED_SNAP_DR1)s , %(DELETED_AMI_DR2)s , %(DELETED_SNAP_DR2)s , %(SUCCESSFUL)s)")
    
    print insert_sql
    
    insert_data = ('SERVER1', '68687687876','2014-12-29 13:27:46', 'us-west-9', 'None', 'None', 'i-gtsuid43', 'ami-9jsh222f', 'DBAPP-SERVER', 'i-4wj333e3', 'ami-73eee351', 'VISTA-SERVER', 'i-5464ssse', 'ami-4ddd2853', 'WS-QSERVER', 'none', 'none', 'none', 'none', 'none', 'none', 'none', 'none', 'none', 1)
    
    cursor.execute(insert_sql, insert_data)
    cnx.commit()
    cursor.close()
    

I am getting the following error and need help in getting rid of this error:

    
    
    /usr/bin/python ./test.py
    insert into qdb1.amis (CUSTOMER_NAME, AWS_ACCOUNT, AMI_START, CRT_REGION_PRIMARY, CRT_REGION_DR1,
    CRT_REGION_DR2, DBAPP_INST_ID, DBAPP_AMI_ID, DBAPP_AMI_NAME, EVISTA_INST_ID, EVISTA_AMI_ID, 
    EVISTA_AMI_NAME, WS_INST_ID, WS_AMI_ID, WS_AMI_NAME, DEL_REGION_PRIMARY, DEL_REGION_DR1, 
    DEL_REGION_DR2, DELETED_AMI_PRIMARY, DELETED_SNAP_PRIMARY, DELETED_AMI_DR1, DELETED_SNAP_DR1,  
    DELETED_AMI_DR2, DELETED_SNAP_DR2, SUCCESSFUL) values ( %(CUSTOMER_NAME)s , %(AWS_ACCOUNT)s , % 
    (AMI_START)s , %(CRT_REGION_PRIMARY)s , %(CRT_REGION_DR1)s , %(CRT_REGION_DR2)s , %(DBAPP_INST_ID)s ,  
    %(DBAPP_AMI_ID)s , %(DBAPP_AMI_NAME)s , %(EVISTA_INST_ID)s , %(EVISTA_AMI_ID)s , %(EVISTA_AMI_NAME)s  
    , %(WS_INST_ID)s , %(WS_AMI_ID)s , %(WS_AMI_NAME)s , %(DEL_REGION_PRIMARY)s , %(DEL_REGION_DR1)s , % 
    (DEL_REGION_DR2)s , %(DELETED_AMI_PRIMARY)s , %(DELETED_SNAP_PRIMARY)s , %(DELETED_AMI_DR1)s , %(DELETED_SNAP_DR1)s , %(DELETED_AMI_DR2)s , %(DELETED_SNAP_DR2)s , %(SUCCESSFUL)s)
    Traceback (most recent call last):
      File "./test.py", line 18, in <module>
        cursor.execute(insert_sql, insert_data)
      File "/usr/lib/python2.6/site-packages/mysql/connector/cursor.py", line 498, in execute
        "Not all parameters were used in the SQL statement")
    mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement
    


Answer: To use "named placeholders" in mysql connector, as you're doing, the second
argument to execute should be a dictionary having those names as its keys, not
a tuple (as you're using) or list. Alternatively, use the "unnamed
placeholder" `'%s'`.

