![]() |
MySQL & Python
Hi.
I am currently using Python 2.5 & MySQL 5.0 w/ the latest MySQLdb module. I am trying to insert rows into the database via MySQLdb. What's odd is that using this code I can successfully run a select query, describe tables, and even create tables: :
import MySQLdbFor some reason though, I cannot seem to insert or delete rows using MySQLdb. The program won't error out or anything, it exits w/ code 0. I've noticed that the changes seems to take in python because when I run a program to pull the rows I just inserted, it will pull them up. If I open the MySQL command line and manually query the table, the table will return an empty set. Is there maybe some code I have to run to update the MySQL database? Any help would be appreciated. |
I think the problem could be that after you insert or delete you have to commit the query by running connection.commit().
http://mysql-python.sourceforge.net/...ection-objects I could be wrong as I have never used MySQLdb but it might be worth a shot edit: check this out http://mysql-python.sourceforge.net/...-won-t-go-away it says that MySQLdb disabled autocommits in version 1.2.0 so you will have to run the connection.commit() before you close the connection or all changes will not be committed to the db. |
Holy Crap dude it worked like a friggin charm, thanks.
I've been through a few tutorials and none of them mentioned the commit() function. Really appreciate it. |
| All times are GMT -5. The time now is 12:47 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC