-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David Mitchell wrote: > Hello, > > I am a complete beginner with Python. I've managed to get mod_python up and > running with Apache2 and I'm trying to a simple insert into a table in a > MySQL database. > > I'm using the MySQLdb library for connectivity. I can read from the database > no problem, but when I do an insert, the value never gets added to the > database, even though there is no error, and the SQL is fine (I print out > the SQL statement in the function). When I copy and paste the sql from my > browser and insert directly into MySQL, it works fine. > [...] Am I doing something obviously incorrect here?
It appears you forgot to call .commit() on the connection to commit your transaction. From what you tell, it also looks like the MySQL commandline tool defaults to autocommit (i. e. each statement is wrapped in an implicit BEGIN ... COMMIT. If you have no idea what a transaction is or what the heck the BEGIN, COMMIT or ROLLBACK commands are for (corresponding to .commit() and .rollback() methods of the DB-API2 connection object, BEGIN is issued implicitly), then the MySQL documentation will probably answer that. HTH, - -- Gerhard -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDZWBndIO4ozGCH14RAuuKAJ9MiUn39dfd0FMclnYBFkXufN/wzwCdG7s4 6Bxj6HdyBbAz7u5O5tu0m7E= =FXrV -----END PGP SIGNATURE----- -- http://mail.python.org/mailman/listinfo/python-list