I'm using MySQLdb.
Alright, I'm doing
import MySQLdb as mysql
db = mysql.connect("localhost", "root", "password", "database")
cu = db.cursor()
rows = cu.execute("INSERT INTO users (user, pass) VALUES ('test', 'test')")
print "rows affected:", rows
cu.close();db.close()
Well, what happens is, it gets executed and prints "rows affected: 1" BUT when I check in my MySQL console no rows are there.
What's the problem? My SQL query is fine, and it works when I do it on the MySQL command line.
EDIT: okay, it works if I add a
db.commit()
. -.-
How can I make it auto-commit? I don't feel like doing that after every query, and my app is always using the same cursor for a long period of time