[DB-SIG] Sybase module 0.35pre2 released
Dave Cole
djc@object-craft.com.au
28 Oct 2002 22:36:20 +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.
NOTES:
In this release the module uses callback instead of inline error
handling from the Sybase CT library. This has caused quite extensive
changes to the threading support inside the low level extension
module.
One of the nice side effects of using callback error handling is that
server errors while executing stored procedures will now be reported
correctly.
FreeTDS support is much improved in this version.
You can build for FreeTDS like this:
python setup.py build_ext -D HAVE_FREETDS -U WANT_BULKCOPY
python setup.py install
The module is available here:
http://www.object-craft.com.au/projects/sybase/download/sybase-0.35pre2.tar.gz
The module home page is here:
http://www.object-craft.com.au/projects/sybase/
CHANGES SINCE 0.35pre1:
* Changed ignored server messages to (5701, 5703). Thanks to Kevin
Jacobs.
* Allocate a new CS_COMMAND for each command executed on a cursor.
This behaves like an explicit close() on the cursor in between
commands. This makes it possible to perform multiple .execute()
commands on a cursor with FreeTDS.
* Added array binding to cursor to gain extra performance. Set the
arraysize cursor attribute before executing a command.
* Made connection locking optional. Sybase.connect(..., locking = 0)
* Native DateTime types now has separate str() and repr(). print
used to display "'11/01/63'".
ARRAY BINDING:
The following is a little test program to see the performance effect
of array binding in the .fetchmany() cursor method.
It looks like the speed was mostly going in function calls due to
locking and single row fetching.
run locking array functions time (ave 10 runs)
test-array l Y N 88586 1.3248 secs
test-array N N 20450 0.9803 secs
test-array al Y Y 9458 0.5188 secs
test-array a N Y 7262 0.5002 secs
- - test-array.py - - - - - - - - - - - - - - - - - - - - - - - -
import sys, Sybase
def array_bind():
db = Sybase.connect('SYBASE', 'sa', '', 'sybsystemprocs',
locking = do_locking)
c = db.cursor()
c.arraysize = 32
c.execute('select text from syscomments')
num_rows = 0
while 1:
rows = c.fetchmany()
if not rows:
break
num_rows += len(rows)
print num_rows, 'rows'
def single_bind():
db = Sybase.connect('SYBASE', 'sa', '', 'sybsystemprocs',
locking = do_locking)
c = db.cursor()
c.execute('select text from syscomments')
num_rows = 0
while 1:
row = c.fetchone()
if not row:
break
num_rows += 1
print num_rows, 'rows'
def main():
if do_array:
array_bind()
else:
single_bind()
do_profile = len(sys.argv) > 1 and sys.argv[1].find('p') >= 0
do_locking = len(sys.argv) > 1 and sys.argv[1].find('l') >= 0
do_array = len(sys.argv) > 1 and sys.argv[1].find('a') >= 0
if do_profile:
import profile
profile.run('main()')
else:
main()
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
http://www.object-craft.com.au