I have been trying this for a while now and have had some serious problems 
with BLOBs. I have taken the DAL out of the equation by using executesql(). 
I am grabbing a picture blob from an existing database (each picture os 
about 35 kb). I am taking the blob and writing it to a file, but only the 
first 4096 bytes are written to the file. Does anyone know what's going on? 
Did I do this wrong? Here's my code:

        folder = os.path.join(self.request.folder, 'uploads')
        
        rows = source.executesql('SELECT TOP 3 * FROM EmployeesPictures;')
        
        for row in rows:
            username = row[0].lower()
            
            id = users_rev[username].id
            picture = row[1]
            if not picture: continue
            
            file = open(os.path.join(folder, username + '.png'), 'wb')
            for i in picture:
                file.write(i)
                
            file.close()

Reply via email to