Re: INSERT statements not INSERTING when using mysql from python

2006-12-30 Thread Tim Roberts
"Ben" <[EMAIL PROTECTED]> wrote: >Perhaps when I'm checking for table existance using mysql through >python I have to be more explicit: > >Where I did have: >USE database; >IF NOT EXISTS CREATE table(. > >Perhaps I need: >USE database; >IF NOT EXISTS CREATE database.table(. > >I'll try it

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
:-) Ok, point taken! I fixed it in the end. It was nothing interesting at all - just a wayward line of code that was doing exactly what I feared - replacing the database each time rather than just when it was needed. Ben Leo Kislov wrote: > Ask Ben, he might know, although he's out to lunch. >

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Leo Kislov
Ask Ben, he might know, although he's out to lunch. Ben wrote: > I'll try it after lunch. Does anyoone know whether this might be the > problem? > > Ben > > > Ben wrote: > > I have found the problem, but not the cause. > > > > I tried setting the database up manually before hand, which let me get

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread timw.google
Not sure if this will help, as you said you already tried autocommit, but did you try to commit after creating the table, then doing all the inserts before commiting on disconnect? (I'm no MySQL or Python guru, but I do use it with python and MySQLdb .) -- http://mail.python.org/mailman/listinfo

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
Perhaps when I'm checking for table existance using mysql through python I have to be more explicit: Where I did have: USE database; IF NOT EXISTS CREATE table(. Perhaps I need: USE database; IF NOT EXISTS CREATE database.table(. I'll try it after lunch. Does anyoone know whether this mi

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
I have found the problem, but not the cause. I tried setting the database up manually before hand, which let me get rid of the "IF NOT EXISTS" lines, and now it works! But why the *** should it not work anyway? The first time it is run, no database or tables, so it creates them. That works. But a

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
Well, I've checked the SQL log, and my insert statements are certainly being logged. The only option left open is that the table in question is being replaced, but I can't see why it should be... Ben wrote: > Nope... that can't be it. I tried running those commands manually and > nothing went wro

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
Nope... that can't be it. I tried running those commands manually and nothing went wrong. But then again when I execute the problematic command manually nothing goes wrong. Its just not executing until the last time, or being overwritten. Ben wrote: > Each time my script is run, the following is

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
Each time my script is run, the following is called: self.cursor.execute("CREATE DATABASE IF NOT EXISTS "+name) self.cursor.execute("USE "+name) self.cursor.execute("CREATE TABLE IF NOT EXISTS table_name ( The idea being that stuf is only created the first time the script is run, and after t

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
One partial explanation might be that for some reason it is recreating the table each time the code runs. My code says "CREATE TABLE IF NOT EXISTS" but if for some reason it is creating it anyway and dropping the one before that could explain why there are missing entires. It wouldn't explain why

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
I initially had it set up so that when I connected to the database I started a transaction, then when I disconnected I commited. I then tried turning autocommit on, but that didn't seem to make any difference (althouh initially I thought it had) I'll go back and see what I can find... Cheers, Ben

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
Ben wrote: > Well that's odd... > > If I place the exact same Insert statement elswhere in the program it > works as intended. > That would suggest it is never being run in its old position, but the > statements either side of it are printing... > > > Ben wrote: > > I don't know whether anyone can

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread johnf
Ben wrote: > I don't know whether anyone can help, but I have an odd problem. I have > a PSP (Spyce) script that makes many calls to populate a database. They > all work without any problem except for one statement. > > I first connect to the database... > > self.con = MySQLdb.connect(user=usern

Re: INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
Well that's odd... If I place the exact same Insert statement elswhere in the program it works as intended. That would suggest it is never being run in its old position, but the statements either side of it are printing... Ben wrote: > I don't know whether anyone can help, but I have an odd prob

INSERT statements not INSERTING when using mysql from python

2006-12-29 Thread Ben
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one statement. I first connect to the database... self.con = MySQLdb.connect(user=username, passwd =password) sel