ORA-01465: invalid hex number in python django

为君一笑 提交于 2019-12-11 03:07:01

问题


I'm trying to upload multiple files in oracle 11g database using python django.

Here's my view

for filecol in request.FILES.getlist('file'):
    filename = filecol.name
    filetype = filecol.content_type
    fileblob = filecol.read()

FileRecord.objects.create(O_FILE_ID=oID, FILE_NAME=filename, FILE_TYPE=filetype, 
    FILE_BLOB=fileblob, DATE_UPLOADED=datetime.datetime.now().replace(microsecond=0))

Then I received this error message

return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-01465: invalid hex number

Here in my models.py

class FileRecord(models.Model):
    O_FILE_ID = models.IntegerField(primary_key=True, validators=[MinValueValidator(1), MaxValueValidator(11)], blank=True, null=True)
    FILE_NAME = models.CharField(max_length=50, blank=True, null=True)
    FILE_TYPE = models.CharField(max_length=50, blank=True, null=True)
    FILE_BLOB = models.FileField()
    DATE_UPLOADED = models.CharField(max_length=50, blank=True, null=True)

    class Meta:
        managed = True
        db_table= 'FILE_RECORD'

    def __str__(self):
        return str(self.O_FILE_ID)

Sample data: filename=Koala.jpg, filetype=image/jpeg, fileblob=''

I'm planning to insert base64 encoding in fileblob if possible.

来源:https://stackoverflow.com/questions/41545110/ora-01465-invalid-hex-number-in-python-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!