4 ms·
One of the things that caused me a headache for about an hour was realising that you had to do a conn.commit() when updating or INSERTing.
by kierank 17y ago
One of the things that caused me a headache for about an hour was realising that you had to do a conn.commit() when updating or INSERTing.
- mgrouchy 17y agoI probably should have mentioned that in the article, truth is it really depends on your set up, most of the mysql databases I have used are not set up for transactions.
- tocomment 17y agoYou can set your connection (possibly your db) to autocommit. I forget how offhand, maybe do a search.
- mgrouchy 17y agoMySQL is set to autocommit by default (you can check with "select @@autocommit", there are probably some other ways to check as well), then it comes to which engine you use, many of them don't support transactions, but some like InnoDB do. So it really all depends. in response to lincolnq below: you are correct, if the engine does support autocommit it is turned on automatically. http://www.python.org/dev/peps/pep-0249/ http://www.python.org/dev/peps/pep-0249/
- lincolnq 17y agoMySQL may be autocommit by default, but I believe the Python DB-API spec (and therefore mysqldb) specifies to turn autocommit off when the connection is opened.