TypeError: can't escape psycopg2.extensions.Binary to binary
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: 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 ()