MySQLdb not updating rows
Bowen
simon at xiano.co.uk
Wed Jun 28 09:15:14 EDT 2006
import md5
import string
import MySQLdb
tc = raw_input("Teacher Code: ")
p = raw_input("New Password: ")
print tc
hash = md5.new()
hash.update(p)
print p
print hash.hexdigest()
h = hash.hexdigest()
boo = raw_input("Sure you want to update password with above details? Y
or N: ")
if boo == 'y':
db = MySQLdb.connect("copweb2", "******", "******", "*******")
cursor = db.cursor()
if cursor.execute("UPDATE teachers SET password = '%s' WHERE
teacher_code = '%s'" % (h, tc)):
print "Done"
else:
print "Error"
else:
print "cancelled"
cursor.close()
db.close()
This code doesn't seem to update my database, anyone any idea why? Is
it me being stupid? It doesn't kick out an error at all.
More information about the Python-list
mailing list