473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python & MySQL

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
3 1734
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Peter Moscatt | last post by:
Will Python work with any of the databases like MySQL... ? Pete
3
by: james blair | last post by:
Hi I have a search page & the reults for the search are fetched from the database. I want that on the results page only first 25 results are shown & a link "next 25 results" be shown.Same for the...
7
by: Matthias Verniers | last post by:
Hello Yesterday I installed Python 2.4. Since I often work with MySQL, I need the MySQLdb module, wich worked fine under 2.3. Now, it doesn't work under 2.4, it says it needs python 2.3 when I...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
16
by: Amir Michail | last post by:
Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it...
13
by: Steven Bethard | last post by:
Jean-Paul Calderone <exarkun@divmod.comwrote: Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
3
by: int32bit | last post by:
I can't figure out why this doesn't work. Any ideas appreciated. conn = MySQLdb.connect (db = "vocab") cursor = conn.cursor () cursor.execute ("SELECT VERSION()") row = cursor.fetchone ()...
0
by: OldManRiver | last post by:
All, I downloaded the OpenEMM (Linux & Windows) to install. The Windows version uses Python as the Installer and the programmer for this installer made some bad assumptions about the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.