473,698 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1752
Okay,

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

db = MySQLdb.connect (user=database_ user,passwd=dat abase_password)

db.autocommit(T rue) <--- 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**********@gm ail.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**********@gm ail.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
1302
by: Peter Moscatt | last post by:
Will Python work with any of the databases like MySQL... ? Pete
3
1508
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 2nd result page. How do I do this?
7
4139
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 try to install the module. Now I have some (rather nooby) questions: 1. Has anyone tried installing MySQLdb 1.0 under Python 2.4 and has he succeeded? Please let me know how to do it or where I can find more information. 2. Is it possible to use...
4
2808
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 http://192.168.1.106/~mlh/credifree/index.php the AMP app still thinks the data resides somewhere else. It runs fine - as long as I leave my LAN's external internet connection up. But if I unplug my LAN from the world, my app locks up. Before I...
16
4010
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 is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be painful, but Eclipse takes
13
2155
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
3011
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 help me out in solving the issue. I'd like to get this solved so I can continue developing with Django using MySQL since that's what my web server uses as well. I'd hate to have to develop using a different database engine on my local...
3
1641
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 () print "server version:", row cursor.close () conn.close ()
0
1161
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 installations. I posted a run-down of the install problems at: http://www.openemm.org/forums/viewtopic.php?p=2101#2101
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.