Sybase module 0.33pre3 released

Dave Cole
14 Feb 2002 23:34:41 +1100

What is it:
The Sybase module provides a Python interface to the Sybase relational
database system.  It supports all of the Python Database API, version
2.0 with extensions.


Since the 0.32 release I have come to the realisation that the Sybase
dynamic SQL functionality is not nearly general enough to use for
correct DB-API functionality.  I have thrown up my hands and gone back
to the drawing board with the high level module.

Status of 0.33pre2:

The 0.33pre2 release seems to be quite solid.  I have not received any
complaints from any of the 10 (count them) people who downloaded the
module.  Ben Gertzfield managed to implement a multi-threaded whois
server on top of the 0.32pre2 release.

Changes for 0.33pre3:

1) Release 0.32pre2 changed the paramstyle to 'format'.  Shai Berger
   sent me some valuable advice on how to continue to send binary
   parameters to the server without using ct_dynamic() so the
   paramstyle is now 'named'.  This means that you can now do this:

     c.execute("select * from titles where title like @arg",
               { '@arg': 'The %' })

2) You can send arguments to Cursor.callproc() the old way:

     c.callproc('sp_help', ['titles'])

   or the new way:

     c.callproc('sp_help', { '@objname': 'titles' })

3) Some internal cursor state constants were privatised (via leading
   '_').  Sadly no money was raised in the process and the conditions
   of the privatisation contract are commercial-in-confidence.

4) You can now compile the extension module without bulkcopy support
   by doing this:

     python build_ext -U WANT_BULKCOPY
     python install

5) The default build does not do threading any more so if you want
   threading enabled you will have to do this:

     python build_ext -D WANT_THREADS
     python install

6) There is some extra debugging detail for CS_DATAFMT which means you
   now get messages like this:

      >>> import Sybase
      >>> db = Sybase.connect('SYBASE', 'sa', '', 'pubs2')
      >>> db._conn.debug = 1
      >>> c = db.cursor()
      ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd1
      >>> c.callproc('sp_help', {'@objname': 'titles'})
      ct_command(cmd1, CS_RPC_CMD, "sp_help", CS_NULLTERM, CS_UNUSED) -> CS_SUCCEED
      ct_param(cmd1, &databuf0->fmt=[name:"@objname" type:CS_CHAR_TYPE status:CS_INPUTVALUE format:CS_FMT_NULLTERM count:1 maxlength:7], databuf0->buff, 6, 0) -> CS_SUCCEED
      ct_send(cmd1) -> CS_SUCCEED
      ct_results(cmd1, &result) -> CS_SUCCEED, CS_ROW_RESULT
      ct_res_info(cmd1, CS_NUMDATA, &value, CS_UNUSED, NULL) -> CS_SUCCEED, 3
      ct_describe(cmd1, 1, &fmt) -> CS_SUCCEED, datafmt0=[name:"Name" type:CS_CHAR_TYPE status:CS_UPDATABLE format:CS_FMT_UNUSED count:0 maxlength:30]
      ct_bind(cmd1, 1, &datafmt0->fmt=[name:"Name" type:CS_CHAR_TYPE status:CS_UPDATABLE format:CS_FMT_UNUSED count:1 maxlength:30], databuf1->buff, databuf1->copied, databuf1->indicator) -> CS_SUCCEED, databuf1
      ct_describe(cmd1, 2, &fmt) -> CS_SUCCEED, datafmt1=[name:"Owner" type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:30]
      ct_bind(cmd1, 2, &datafmt1->fmt=[name:"Owner" type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:1 maxlength:30], databuf2->buff, databuf2->copied, databuf2->indicator) -> CS_SUCCEED, databuf2
      ct_describe(cmd1, 3, &fmt) -> CS_SUCCEED, datafmt2=[name:"Type" type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:22]
      ct_bind(cmd1, 3, &datafmt2->fmt=[name:"Type" type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:1 maxlength:22], databuf3->buff, databuf3->copied, databuf3->indicator) -> CS_SUCCEED, databuf3
7) There is some initial work to support FreeTDS.  One of the problems
   with FreeTDS is that it does not support inline error handling.
   The callback error handling works well if you do not compile for
   threads support, but causes problems when compiled for threading.

   The problem occurs when the extension module releases the global
   interpreter lock when calling the Sybase CT library.  A Python
   callback causes the interpreter to be reentered by the callback
   which leads to bad things when the following warning from the
   Python include file ceval.h is violated:


   At the moment the module will compile for FreeTDS (at least it does
   on my machine) and some things do work.  All you have to do is
   compile like this:

     python build_ext -D HAVE_FREETDS
     python install

   There is no error handling and reporting for FreeTDS yet.

8) The was a minor change to for:

   a) Solaris.  It no longer staticly links the libcomn.a Sybase

   b) Linux.  No longer looks for both libsybtcl and libtcl.  Now
      looks for libinsck.

Extra Pleading:

Please download the pre-release version, try it out, and then send me
some mail telling me what you found.  You would be surprised at how
little mail I get regarding the Sybase module, I really do need your
help.  If more than 10 people tried the module we would all benefit...

The module is available here:

The module home page is here:

- Dave