Blobs with ADO

Gabe Gittings ggittings at arraybiopharma.com
Wed Dec 4 14:18:51 EST 2002


I am attempting to insert excel files into an access db through a
small python app. I have run into difficulty because the docs. are so
slim however. The following is what I have so far.

   def insertBLOB(self,table,blobField, blobFileLocation):
        file = open(blobFileLocation,'rb')
        
        mstr = win32com.client.Dispatch(r'ADODB.Stream')
        mstr.Type = win32com.client.constants.adTypeBinary
        mstr.Open()
        mstr.Write(file)
        mstr.Position = 0
        
        self.openRcd(table)  #method that opens record set via ADO
        self.acsRst.AddNew()
        
        self.acsRst.Fields.Item(blobField).Value = mstream.Read()
        self.acsRst.Update()


Now I know that the Write() method of the Stream object only accepts
buffers as COM variants but I don't have the slightest clue as to how
to get the file into an array that can be passed to the Stream object.
The documentation is virtually non-existant. Also I am not sure if the
Stream Object is the best way to go in the first place. Any help would
be much appreciated.

Thanks



More information about the Python-list mailing list