TypeError: can't escape psycopg2.extensions.Binary to binary

匿名 (未验证) 提交于 2019-12-03 01:42:02

问题:

I try to store binary file into postgresql through sqlalchemy and file is uploaded from client. A bit google on the error message brings me to this source file:" wrapped object is not bytes or a buffer, this is an error"

   binaries = []     for f in request.files.values():         if f and allowed_file(f.filename):             fn = secure_filename(f.filename)             file_path = os.path.join(basedir, fn)             f.save(file_path)             #data = f.read()             data = open(fn, 'rb').read()             binaries.append(psycopg2.Binary(data))             f.close()     #does the escaping     mytable=mytable(     ...,     document1 = binaries[0]     ...     )     #Model     class mytable(mydb.Model):       document1 = mydb.Column(mydb.LargeBinary())
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!