MySQLdb not INSERTING, _mysql does fine.

Posted by Mad_Casual on Stack Overflow See other posts from Stack Overflow or by Mad_Casual
Published on 2010-04-07T06:41:23Z Indexed on 2010/04/07 6:43 UTC
Read the original article Hit count: 330

Filed under:
|
|

Okay, I log onto the MySQL command-line client as root. I then open or otherwise run a python app using the MySQLdb module as root. When I check the results using python (IDLE), everything looks fine. When I use the MySQL command-line client, no INSERT has occurred. If I change things around to _mysql instead of MySQLdb, everything works fine. I'd appreciate any clarification(s).

"Works" until IDLE/Virtual machine is reset:

<pre><code>import MySQLdb
db = MySQLdb.connect(user='root', passwd='*******',db='test')
cursor = db.cursor()
cursor.execute("""INSERT INTO test VALUES ('somevalue');""",)</code></end>

Works:

<pre><code>import _mysql
db = _mysql.connect(user='root', passwd='*******',db='test')
db.query("INSERT INTO test VALUES ('somevalue');")</code></end>

System info: Intel x86 WinXP Python 2.5 MySQL 5.1.41 MySQL-Python 1.2.2

© Stack Overflow or respective owner

Related posts about python

Related posts about mysql