By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,592 Members | 1,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,592 IT Pros & Developers. It's quick & easy.

Python & MySQL

P: n/a
Hi all,

I've got a weird problem. I was running Python 2.3 and MySQLdb and had
everything running fine.

Cutting to the chase: After upgrading to 2.4 (and latest modules) the
MySQLdb functions in Python can connect to the database, do queries and
do inserts.

Or rather, it seems to do inserts. If I just run in the Python command
line and manually connect to the database and do an insert and then a
query on what I just inserted the info is there.

However when I use SQLyog to look at the database the info isn't there.
When I close down Python, restart, reconnect and query the info isn't
there.

Info inserted from SQLyog is persistant.

Has anyone had any problems like this before?

thanks,

jason

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Okay,

I had the brilliant idea right after posting to google the newsgroups
on this.

db = MySQLdb.connect(user=database_user,passwd=database _password)

db.autocommit(True) <--- One little line!
There ya go. Works like a champ. I swear I was pulling my hair out
yesterday over this.

Jul 18 '05 #2

P: n/a
ja**********@gmail.com wrote:
Hi all,

I've got a weird problem. I was running Python 2.3 and MySQLdb and had
everything running fine.

Cutting to the chase: After upgrading to 2.4 (and latest modules) the
MySQLdb functions in Python can connect to the database, do queries and
do inserts.

Or rather, it seems to do inserts. If I just run in the Python command
line and manually connect to the database and do an insert and then a
query on what I just inserted the info is there.

However when I use SQLyog to look at the database the info isn't there.
When I close down Python, restart, reconnect and query the info isn't
there.

Info inserted from SQLyog is persistant.

Has anyone had any problems like this before?

thanks,

jason

I suspect you are forgetting to commit your changes to the database, so
they are being rolled back when you close your connection.

regards
Steve
--
Steve Holden +1 703 861 4237 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/

Jul 18 '05 #3

P: n/a
ja**********@gmail.com wrote:
Hi all,

I've got a weird problem. I was running Python 2.3 and MySQLdb and had
everything running fine.

Cutting to the chase: After upgrading to 2.4 (and latest modules) the
MySQLdb functions in Python can connect to the database, do queries and
do inserts.

Or rather, it seems to do inserts. If I just run in the Python command
line and manually connect to the database and do an insert and then a
query on what I just inserted the info is there.

However when I use SQLyog to look at the database the info isn't there.
When I close down Python, restart, reconnect and query the info isn't
there.

Info inserted from SQLyog is persistant.

Has anyone had any problems like this before?

thanks,

jason

I suspect you are forgetting to commit your changes to the database, so
they are being rolled back when you close your connection.

regards
Steve
--
Steve Holden +1 703 861 4237 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.