1

I'm trying to use connector python for inserting records into MySQL

I'm unable to understand why i'm getting

ProgrammingError: Failed processing format-parameters; Python 'list' cannot be converted to a MySQL type

This is my simple program

import mysql.connector

 #All variables like user_name etc. are initialized


cnx = mysql.connector.connect(user='root',password='password',database='consumer')
curA = cnx.cursor(buffered=True)

insert_query = "INSERT INTO sno_social_listener( user_name, user_profile_url, message_url, message_title, message_content, created_on ) VALUES ('%s',  '%s',  '%s',  '%s',  '%s',  '%s')"

curA.execute(insert_query,(user_name, user_profile_url,complaint_source_url, message_title, message_content,created_on))
1
  • Can you add a print (user_name, user_profile_url,complaint_source_url, message_title, message_content,created_on) Commented Jul 21, 2015 at 12:31

1 Answer 1

1

This should work.

curA.execute(insert_query %(user_name, user_profile_url,complaint_source_url, message_title, message_content,created_on))

Also at end

cnx.commit()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.