[python-sybase] Problem with CS_LONG

Dave Cole djc at object-craft.com.au
Wed, 02 Jun 2004 10:20:06 +1000


Paul Rensing wrote:

>Hi. I recently updated to FreeTDS 0.62.3 and Sybase 0.36 (used to have
>0.36pre6 installed). Now, I am suddenly having a problem reading tables
>I could read before. 
>
>The culprit is a column which is of type CS_LONG_TYPE. There is no
>conversion method in databuf.c DataBuf_item() for that type. I fixed it
>(correctly?) by adding at line 183:
>
>    case CS_LONG_TYPE:
>	return PyLong_FromLongLong(*(long long *)item);
>
>Note I could not use "(CS_LONG *)" because the header file from FreeTDS
>lists CS_LONG as an int (4 bytes) instead of a long long (8 bytes).
>
>Does this make sense, or am I missing something?
>  
>
You should probably also add code that allows you to copy Python longs 
into a CS_LONG_TYPE buffer in the DataBuf_ass_item() function.  Without 
doing this you will not be able to pass CS_LONG values back to Sybase.  
This is not really such a big deal as Sybase will convert from other types.

- Dave

-- 
http://www.object-craft.com.au