[DB-SIG] Problems w/BLOBs

working4aliving working4aliving@hotmail.com
Tue, 17 Dec 2002 23:21:42 -0500


I'm a newbie w/ this george, but in Zope, I return what you would have as
res_obj and I can then view the blob...
when I return from my python function the out_string, as you do, i get
"machine code" on the screen... (hahaha old 80's joke:)  ).
I'm not sure if this helps you.  here's my script (realizing it's called
from within zope)

result = []
lob = ['image1']
for row in context.sqlimage1(id=id):
   lob = row['image1']
#  result.append({'image1': lob.read()})
# above was remmed
return lob

Good luck, blobs suck (only kidding, but it DOES rhyme)

Bob



----- Original Message -----
From: "George Jones" <gsjonesjr@yahoo.com>
To: <db-sig@python.org>
Sent: Tuesday, December 17, 2002 6:27 PM
Subject: [DB-SIG] Problems w/BLOBs


> Hello,
>      I'm trying to store binary data in a BLOB in an
> Oracle 9i db(Is that, 9i rather than 8, my problem?).
> I'm new to Python, and very new to DCOracle2, which is
> the module I'm using to connect to the db.  I'm able
> to load the data into the db, although not in the way
> that the documentation suggests, but when I retrieve
> it the LobLocator Object's read method wont work.
>
> in_file = open('boo','rb')
> input_string = in_file.read()
>
> import DCOracle2
> db = DCOracle2.connect('blah/blah')
> c = db.cursor()
> c.execute('insert into my_blob values(:1, :2)', 1, \
> DCOracle.Binary(input_string, 'SQLT_BLOB')
> db.commit()
> c.execute('select file_data from my_blob where
> file_id\ = 1')
> result = c.fetchone()
> res_obj = result[0]
> print res_obj.length() # this gives right length
> 138240
> out_string = res_obj.read() # this gives nothing
>
> So what am I doing wrong?
> TIA
> GSJ
>
>
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
>
> _______________________________________________
> DB-SIG maillist  -  DB-SIG@python.org
> http://mail.python.org/mailman/listinfo/db-sig
>