Hi,
I've been using pyDB2 and editing here and there, just to get additional
support for the features that I need. I never worked on open source code
before so I don't really know about editing and sharing etiquette for
this, so pardon me if I'm doing anything wrong.
Attached is edited version of _db2_module.c and _db2_module.h - I just
moved it to .h just to reduce .c size. - and DB2.py which supports,
1. procedure calling
2. large LOB support thru file handle.
3. scrollable cursor
Usage for number 1 is unchaned.
For large LOB support, here is the sample code.
import os
import DB2
f = open( 'sample.jpg' )
data = f.read()
f.close()
conn = DB2.connect( dsn='test', uid='testuser', pwd='testpass')
curs = conn.cursor()
curs.execute( 'INSERT INTO test(Data) values(?)", data ) ;
curs.close()
conn.close()
scrollable cursor, you'll need to set bScrollable = 1 in cursor
creation. Only static cursor is supported.
import DB2
conn = DB2.connect( dsn='test', uid='testuser', pwd='testpass')
curs = conn.cursor(bScrollable=1)
curs.execute( 'select * from test')
curs.fetchscroll( size=10, orient = 5, offset = 5 )
# this will get you record set size of 10, starting from offset 5 from
absolute position ( SQL_FETCH_ABSOLUTE ).
scrollable cursor will be a bit slower than non-scrollable cursor, but
good thing with that is, SQLRowCount will return row count for SELECT
command with scrollable cursor.
Thanks,
Eunsoo Park
|