[python-sybase] Error in ct_options
Dave Cole
djc at object-craft.com.au
24 Jan 2003 12:16:07 +1100
> I am getting Sybase.Error: ct_options when connecting to MSSQL or
> Sybase. If I comment out the CS_OPT_CHAINXACTS line, it seems to
> work for simple selects. tsql from freetds, today's version works
> fine, so I suppose my freetds.conf file is right. What is the next
> place to look?
The CS_OPT_CHAINXACTS option is there to conform to the DB-API
specification
http://www.python.org/topics/database/DatabaseAPI-2.0.html
Connection Objects
commit()
Commit any pending transaction to the database. Note that if the
database supports an auto-commit feature, this must be initially
off. An interface method may be provided to turn it back on.
Database modules that do not support transactions should
implement this method with void functionality.
I probably should silently ignore problems setting this option...
> I get the following when connecting to MSSQL2000:
>
> marcos@cynar:~/sybase-0.36pre3$ python -c "import
> Sybase;Sybase._ctx.debug = 1;Sybase.connect('cazalla','sa','xxx')"
> ct_con_alloc(ctx0, &conn) -> CS_SUCCEED, conn0
> ct_con_props(conn0, CS_SET, CS_USERNAME, "sa", CS_NULLTERM, NULL) ->
> CS_SUCCEED
> ct_con_props(conn0, CS_SET, CS_PASSWORD, "xxx", CS_NULLTERM, NULL) ->
> CS_SUCCEED
> servermsg_cb
> servermsg_cb
> ct_connect(conn0, "cazalla", CS_NULLTERM) -> CS_SUCCEED
> ct_options(conn0, CS_SET, CS_OPT_CHAINXACTS, 1, CS_UNUSED, NULL) ->
> CS_FAIL
> ct_cancel(conn0, NULL, CS_CANCEL_ALL) -> CS_SUCCEED
> Traceback (most recent call last):
> File "<string>", line 1, in ?
> File "Sybase.py", line 768, in connect
> strip, auto_commit, delay_connect, locking)
> File "Sybase.py", line 608, in __init__
> self.connect()
> File "Sybase.py", line 633, in connect
> self._raise_error(Error, 'ct_options')
> File "Sybase.py", line 621, in _raise_error
> raise exc(text)
> Sybase.Error: ct_options
> ct_con_props(conn0, CS_GET, CS_CON_STATUS, &value, CS_UNUSED, NULL) ->
> CS_SUCCEED, CS_CONSTAT_CONNECTED
> ct_close(conn0, CS_OPT_STATS_IO) -> CS_SUCCEED
> ct_con_drop(conn0) -> CS_SUCCEED
Can you try this patch (to 0.36pre3) for me (contains changes for
Valerie R. Coffman as well)?
- Dave
--- Sybase.py 23 Jan 2003 10:11:02 -0000 1.56
+++ Sybase.py 24 Jan 2003 01:13:55 -0000
@@ -158,6 +158,8 @@
fmt.count = count
if fmt.datatype == CS_VARBINARY_TYPE:
fmt.datatype = CS_BINARY_TYPE
+ if fmt.maxlngth > 65536:
+ fmx.maxlength = 65536
status, buf = cmd.ct_bind(i + 1, fmt)
if status != CS_SUCCEED:
raise Error('ct_bind')
@@ -629,8 +631,7 @@
self._raise_error(Error, 'ct_connect')
self._is_connected = 1
status = conn.ct_options(CS_SET, CS_OPT_CHAINXACTS, not self.auto_commit)
- if status != CS_SUCCEED:
- self._raise_error(Error, 'ct_options')
+ self.auto_commit = (status != SUCCEED)
finally:
self._unlock()
if self.database:
--
http://www.object-craft.com.au