Re: Sybase.py with MSSQL and BIGINT (8 byte integer) datatype Supported???

Paul Rensing <[email protected]> Thu, 08 Sep 2005 22:36:16 -0400
Newsgroups gmane.comp.python.sybase
Message-ID <[email protected]>
Bradley,

I had this same problem. I patched the code, but just for reads (I don't
need to write those values). I have attached the patch file. 

Dave Cole, can we get these into the repository?

	Paul Rensing

On Mon, 2005-08-29 at 17:05 -0400, Bradley Feldman wrote:
> Does not seem so....  Anyone have any ideas for a quick patch?   Right now
> I'm typecasting back done to int type (4 byte).
> 
> Thanks,
> 
> *Bradley
> 
> Here's the traceback:
> 
>   File "/usr/lib/python2.4/site-packages/Sybase.py", line 392, in start
>     return _FetchNow.start(self, arraysize)
>   File "/usr/lib/python2.4/site-packages/Sybase.py", line 324, in start
>     self._row_result()
>   File "/usr/lib/python2.4/site-packages/Sybase.py", line 345, in
> _read_result
>     while _fetch_rows(self._cmd, bufs, logical_result):
>   File "/usr/lib/python2.4/site-packages/Sybase.py", line 267, in
> _fetch_rows
>     rows.append(_extract_row(bufs, 0))
>   File "/usr/lib/python2.4/site-packages/Sybase.py", line 242, in
> _extract_row
>     row[col] = _column_value(buf[n])
> TypeError: unknown data format
> 
> ---
> 
> def _column_value(val):
>     if use_datetime and type(val) is DateTimeType:
>         return DateTime.DateTime(val.year, val.month + 1, val.day,
>                                  val.hour, val.minute,
>                                  val.second + val.msecond / 1000.0)
>     else:
>         return val
> 
> def _extract_row(bufs, n):
>     '''Extract a row tuple from buffers.
>     '''
>     row = [None] * len(bufs)
>     col = 0
>     for buf in bufs:
> --->>>> row[col] = _column_value(buf[n])  <-----  ERROR HERE
>         col = col + 1
>     return tuple(row)
> 
> _______________________________________________
> Python-sybase mailing list
> [email protected]
> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase
-- 
Paul Rensing <[email protected]>

_______________________________________________
Python-sybase mailing list
[email protected]
https://www.object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase
databuf.patch (text/x-patch, 355 B)
--- databuf.c~	2002-12-23 22:23:39.000000000 -0500
+++ databuf.c	2005-07-18 12:28:01.000000000 -0400
@@ -180,6 +180,9 @@
     case CS_INT_TYPE:
 	return PyInt_FromLong(*(CS_INT*)item);
 
+    case CS_LONG_TYPE:
+	return PyLong_FromLongLong(*(long long*)item);
+
     case CS_MONEY_TYPE:
 	return (PyObject*)money_alloc(item, CS_MONEY_TYPE);