[python-sybase] handling SQL errors

Karl Diedrich diedrich at myriad.com
Tue, 24 Feb 2004 10:41:59 -0700


This problem has been brought up before.
see: 
https://www.object-craft.com.au/pipermail/python-sybase/2003-December/000202.html


When an SQL command with an error is sent
(for example a query from a table that doesn't exist).

When you try to use the connection again (with the corrected SQL for 
example) you get an error like:

Traceback (most recent call last):
   File "/usr/local/lib/python2.3/site-packages/Sybase.py", line 157, in 
_clientmsg_cb
     raise DatabaseError(_fmt_client(msg))
Sybase.DatabaseError: Layer: 1, Origin: 1
ct_cmd_drop(): user api layer: external error: This routine can be 
called only if the command structure is idle.

I think it would be better to send a warning and return the connection 
to a usable state.



My particular problem is that Sybase connects to my default database 
first and then switches to the database I specified.

I have to log into several Sybase server instances and when I log into a 
server that doesn't have my default database I get an error every time 
so I can never get connected.


-- 
Karl Diedrich
Programmer III
Myriad Genetics, Inc.
320 Wakara Way
Salt Lake City, UT 84108
http://www.myriad.com/
(801) 883-3246