1

I have added new column to the existing mysql table with default value as '0'. Ia m trying to update those values to '1' using python script but it does not have any effect on the table.

on the log

SELECT * FROM `customer_1`.`violations` WHERE 0=1

this is my python script:

#!/usr/bin/env python

import os, sys
from mydb import cursor
from twisted.enterprise import util as dbutil
from MySQLdb import escape_string



sql ="UPDATE `customer_1`.`violations` SET `flag`='1' WHERE `flag`='0' ";

print sql
cursor.execute(sql)

It works when I run the same statment on mysql.

Thanks

2
  • Remove the quotes from 0 Commented Nov 18, 2015 at 15:18
  • Tried that still the same error. Commented Nov 18, 2015 at 15:21

1 Answer 1

1

Don't you need to do commit after execute the statement?

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

1 Comment

AttributeError: 'Cursor' object has no attribute 'commit' -error

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.