0

I am having a hard time using the MySQLdb module to insert information into my database. I need to insert 2 variables into the table.My table is userid,the type of user_id is varchar,the type of count is int.

  SQL = 'select user_id,count(*)AS num from client1 group by user_id order by count(*) desc;'
  for row in cursor.execute(SQL):
       a = row.user_id
       b = row.num
       cursormysql.execute("insert into userid(user_id,count) VALUES (%s,%s))",(a,b))
       db.commit()
1
  • 1
    Please edit your question to include your code and the error as text, rather than images. Imagine the one person who is able to help you is very busy and won't bother waiting for images to load to answer a question. Commented Feb 5, 2016 at 2:55

1 Answer 1

1

Your parenthesis do not match on cursormysql.execute("insert into userid(user_id,count) VALUES (%s,%s))",(a,b))

Try like cursormysql.execute("insert into userid(user_id,count) VALUES (%s,%s)",(a,b))

Sign up to request clarification or add additional context in comments.

1 Comment

) right before double quotes see my updated answer

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.