Newbie: Getting Image From Disk into Buffer

Ashley Lloyd ashleylloyd at hotmail.com
Wed Jan 7 09:58:41 EST 2004


I have been trying to get an image into an interbase database (see earlier 
post), and came across a post made on a list some time ago (I ignored it 
earlier as we use kinterbasDB not gvib, but I thought I'd try using it in 
kinterbasDB anyway):

________________________________________________________________
<snip>

I think I can provide some information. I have added a jpg to an interbase
table and have successfuly displayed it in ZOPE.  First off you may know
that Interbase does not store BLOB data directly in a table's blob column.
It stores the data elsewhere and then stores a "pointer" to it in the
table column.  This means that BLOB data MUST be inserted via program code
and thus you cannot do the following in a Zope SQL Method:

insert into the_table (blob_column) values (blob_data)

If you are using the gvibDA you can code an external method to do this:

import gvib
cn = gvib.connect(...)
cr = cn.cursor()
cr.execute('insert into the_table (blob_column values (?)', (blob_data,))
cn.commit()
cr.close()
cn.close()

</snip>
________________________________________________________________

I apologise for my ignorance (newbie, sorry), but can anyone tell me how it 
is that you get the image from disk into blob_data? I have tried several 
ways of opening up the image into a buffer, but it always seems to place 
into the database a string of either the name of the image on disk 
('c:/image.bmp', say), or text such as the following:
<open file 'c:/image.bmp', mode 'rb' at 0x009F06A0>

Once again I apologise for my stupidity (and for making 3 requests today - I 
am trying to figure them out myself, honest!), but if someone could tell me 
how I get the image into blob_data (which I assume is a buffer), I'd be very 
grateful.

TIA

Ashley

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger





More information about the Python-list mailing list