[Tutor] Finding out what causes the crash

Charlie Clark charlie@begeistert.org
Tue Feb 4 10:33:02 2003


On 2003-02-04 at 14:06:38 [+0100], Magnus Lycka wrote:
> At 12:25 2003-02-04 +0100, Charlie Clark wrote:
> >What is the best way to find out more about what's happening?
> 
> A start is to either run in a debugger or insert print statements in 
> strategic places to find out where it happens.

I've managed to locate the statement which causes the problems.
I broke the insert into chunks of 100 and ran this using the debugger in 
IDLE and couldn't see anything suspicious. However, because the debugger 
stopped execution every 100 inserts I was able to go through more loops 
than just letting the program run through all of them. I'll try building in 
a few seconds pause and see how that works.

Here is the offending code:
print count,"Arztkammer %s, PT-Kammer %s, KV %s, KV-Nr %s, PT-Nr %s" 
%(id_arztkammer, id_pt_kammer, id_kv, kv_nr, pt_nr)
mycursor.execute('INSERT into therapist (id_person, id_arztkammer, 
id_pt_kammer, id_kv, pt_nr, kv_nr)\
                          VALUES (%s, %s, %s, %s, %s, %s)', \
                        (id_person, id_arztkammer, id_pt_kammer, id_kv, 
pt_nr, kv_nr) )

I'm not the world's best DB-programmer but this looks okay to me and it 
doesn't cause syntax errors in Python or PostgreSQL.

One of the offending lines is:
Arztkammer None, PT-Kammer None, KV 20, KV-Nr 6121101, PT-Nr None

which looks perfectly harmless to me.

When running the script in a DOS window Abnormal Program Termination seems 
to be routine independent of the amount actually processed. The program has 
lots of inserts but this is the only that causes problems; if I comment it 
out I don't get any errors. I'm running psycopg 1.0.12 on windows and 
trying to get a more up to date binary. I'm also in contact with Federico 
di  Georgio about psycopg anyway.