i have implemented the getPyObject() for myself, and it works.
    But i don't understand fully what happens when  invoking the cursor's "fetch" method(what's the state of  parameters passed to  handler?), so maybe there're problems i don't know. wish your advices.
   BTW, i notice that zxJDBC has to the attribute "autocommit" before i assign it, so after assgin autocommit = 0, what should i do to resume the default value, "autocommit = 1" or delete it?  i have adopted the first way,but i'm not sure.  below is my program.
Thank u very much!
from com.ziclix.python.sql import zxJDBC
from com.ziclix.python.sql import DataHandler
from org.python.util import PythonObjectInputStream
class OracleHandler(DataHandler):
    def __init__(self,handler):
        self.handler = handler
    def getPyObject(self, set, col, datatype):
        if datatype == zxJDBC.BLOB:
            blob = set.getBlob(col)
            stream = PythonObjectInputStream(blob.getBinaryStream())
            pyobject = stream.readObject()
            pyobject = self.handler.getPyObject(set, col, datatype)           
        return pyobject
best regards,
Brian Zimmer <bzimmer@ziclix.com> wrote:
It comes back as a byte array because there was no precedence in the
Python DB API to return a BLOB. It is possible to write a custom
DataHandler which will return a BLOB instance so that you can
manipulate it. You can implement getPyObject() and return the
appropriate wrapped Java instance so that you can access the BLOB as
you would with JDBC. From what I remember I spent a lot of time trying
to get Oracle's BLOBs to work correctly for me and I found it somewhat
difficult mapping it into the Python DB API. I did a lot of work with
Informix's CLOBs but always returned them as a large string so it lost
a lot of the advantages of the CLOB datatype. In any case email if you
need more help or want a better roadmap for what to do.



On Wednesday, October 22, 2003, at 07:51 AM, whamle li wrote:

> ?lt;br>> hello ,friends
> ?lt;br>>      For my question, i tried to simulate the example in zxJDBC
> documentation in interactive model,as below:  ?lt;br>> ?lt;br>>   from com.ziclix.python.sql import zxJDBC?lt;br>> ?from com.ziclix.python.sql.handler import OracleDataHandler?lt;br>> ?lt;br>> ?zxJDBC.autocommit = 0
> ?lt;br>> ?#settings
> ?driver = 'oracle.jdbc.driver.OracleDriver'
> ?url = 'jdbc:oracle:thin:@localhost:1521:mydb'
> ?username, passwd = 'test', 'test'
> ?lt;br>> ?#get connection and cursor
> ?db = zxJDBC.connect(url,username,passwd,driver)
> ?c = db.cursor()
> ?lt;br>> ?#bind oracle handler
> ?c.datahandler = OracleDataHandler(c.datahandler)
> ?lt;br>> ?#try to insert a blob value
> c.execute("insert into table(BLOB_COL) values(?),['testString']," +
>                "{0:zxJDBC.BLOB}")
> ?lt;br>>   The last statement triggered a error of unsupported sql92 sign: 42:
> 0 [SQLCode: 17034], then i tried another way:
> ?lt;br>> #insert an empty BLOB
>  c.execute('insert into table(BLOB_COL) values(EMPTY_BLOB())')
> ?lt;br>> #get the empty blob to update
> c.execute("select BLOB_COL from table")
> ?lt;br>> result = c.fetchone()[0]
> ?lt;br>> unfortrenately, the result is not a BLOB but an array([],byte).
> ?lt;br>> i think the focus of handling BLOB is getting a BLOB object, but how?
> ?lt;br>> any advise,reference or example will be very helpful.
> ?lt;br>> thank you in advance
> ?lt;br>> regards
>           ?lee
> ?lt;br>> ?lt;br>> ?lt;br>> ?lt;br>> ?lt;br>> ?lt;br>> ?lt;br>> ?lt;br>> ?lt;br>>   ?lt;br>>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around