I start off with an empty table. Then I run a short python script using MySQLdb 1.2.2 over Python 2.5.4 that a) creates several columns and b) inserts some data into the table by using:
INSERT INTO table_a (column_a,column_b) VALUES ("abc","def")
For some reason the script works on one MySQL DB on a linux machine and doesn't on a MySQL DB on a Vista machine.
And now for the interesting part:
The columns ARE created. therefore the python script DOES reach the db. Even more curiously, the table I'm using has a self incrementing integer column, and when I tried to enter some data into the table manually, I discovered that the index given matches EXACTLY to the number of rows I tried to insert with the python script. I ran the python script several more times, of course nothing was added to the table, but adding a new row indeed showed the index advanced precisely, as if the data was inputted and discarded.
I'm a newbie, so if you need any info, please tell me how to get it. I'm using the latest MySQL distribution (downloaded on 22Feb/2009)
I'm not sure if this is relevant, but I'm using utf8 configuration. Tried both with strict mode and without, same results.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A few interesting facts:
1) As I said, my code first uses "ALTER TABLE" commands to add columns, and only then inserts data. It's interesting to note that the columns were added and that the ALTER TABLE commands weren't buffered.
2) I executed close to 500 INSERT INTO commands and they were ALL buffered.
3) I was missing is the conn.commit() and the conn.close(). I guess each one of them would of solved the problem, as close() includes a commit().
4) I did have cursor.close() - and this is interesting - I thought (and saw in some forum) that this would be enough to commit the commands. Apparently it isn't
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your symptom sounds like the problem where the MySQL implicit transaction is never closed and thus the data is never committed. The MySQL library keeps an implicit transaction open by default; if you never call connection.commit() the data is not actually committed to the database. However, I don't know why that would be different between Linux and Windows; I've moved programs between the platforms a number of times without observing any difference in this behavior.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I start off with an empty table. Then I run a short python script using MySQLdb 1.2.2 over Python 2.5.4 that a) creates several columns and b) inserts some data into the table by using:
INSERT INTO table_a (column_a,column_b) VALUES ("abc","def")
For some reason the script works on one MySQL DB on a linux machine and doesn't on a MySQL DB on a Vista machine.
And now for the interesting part:
The columns ARE created. therefore the python script DOES reach the db. Even more curiously, the table I'm using has a self incrementing integer column, and when I tried to enter some data into the table manually, I discovered that the index given matches EXACTLY to the number of rows I tried to insert with the python script. I ran the python script several more times, of course nothing was added to the table, but adding a new row indeed showed the index advanced precisely, as if the data was inputted and discarded.
I'm a newbie, so if you need any info, please tell me how to get it. I'm using the latest MySQL distribution (downloaded on 22Feb/2009)
I'm not sure if this is relevant, but I'm using utf8 configuration. Tried both with strict mode and without, same results.
Thank you - it worked!
I don't know why there's a difference between my Linux MySQL install and my Vista MySQL install, but it's there.
Just to be on the safe side, the order should be as follows, right?:
conn.commit()
cursor.close()
conn.close()
A few interesting facts:
1) As I said, my code first uses "ALTER TABLE" commands to add columns, and only then inserts data. It's interesting to note that the columns were added and that the ALTER TABLE commands weren't buffered.
2) I executed close to 500 INSERT INTO commands and they were ALL buffered.
3) I was missing is the conn.commit() and the conn.close(). I guess each one of them would of solved the problem, as close() includes a commit().
4) I did have cursor.close() - and this is interesting - I thought (and saw in some forum) that this would be enough to commit the commands. Apparently it isn't
Your symptom sounds like the problem where the MySQL implicit transaction is never closed and thus the data is never committed. The MySQL library keeps an implicit transaction open by default; if you never call connection.commit() the data is not actually committed to the database. However, I don't know why that would be different between Linux and Windows; I've moved programs between the platforms a number of times without observing any difference in this behavior.