ibmdb / python-ibmdbsa

Automatically exported from code.google.com/p/ibm-db.ibm-db-sa
Apache License 2.0
40 stars 59 forks source link

Blob data is not saved correctly #64

Closed bttong closed 5 years ago

bttong commented 5 years ago

I have the following table defined:

class FileStore(_Base):
  __tablename__ = 'file_storage'

  uuid = Column('uuid', String(48), primary_key=True)
  filename = Column('filename', String(255))
  filecontent = Column('filecontent', BLOB(1048576), nullable=False)
  last_update = Column('last_update', DateTime)

  def __init__(self, attrs):
    self.uuid = attrs['uuid']
    self.filename = attrs['filename']
    self.filecontent = attrs['filecontent']
    self.last_update = attrs['last_update']
    print('filecontent length: {}'.format(len(self.filecontent)))

Before calling session.add(record) to insert new row to DB2, the print statement show that the file (read in as binary) has 4102461 bytes. The record is inserted without error. However, the query to retrieve the same record results only 46 bytes for filecontent.

Please advice.

abhi7436 commented 5 years ago

I am looking into it. will update you shortly.

abhi7436 commented 5 years ago

I am able to reproduce it and found out the root cause. working on fix.

abhi7436 commented 5 years ago

with this fix issue is resolved. https://github.com/ibmdb/python-ibmdb/commit/bb24a0eb85adce627e9dcf65db88b2e514683c01