python二进制数据存入数据库,将二进制文件到MSSQL数据库(VARBINARY)与Python pymssql...

在Pyramid Web应用中,使用pymssql尝试通过存储过程将二进制数据插入MSSQL数据库遇到问题。数据库列类型为VARBINARY(MAX),错误提示不允许从varchar隐式转换为varbinary(max)。解决方案可能需要显式转换varchar数据。
摘要由CSDN通过智能技术生成

I'm trying to insert binary data into an MSSQL database using stored procedures from within an pyramid web application using pymssql.

The MSSQL datatype for the respective column is varbinary(max).

My question is: What does the varbinary datatype of the MSSQL database expect me to do with the binary file before inserting it?

Here's what I've been trying:

with open(tmp_file, 'rb') as content_file:

filecontent = content_file.read()

... and then pass the value of filecontent to the stored procedure.

tmp_file in this case is a valid path to a .png file.

The MSSQL db answers with the following error:

*** DatabaseError: (257, 'Implicit conversion from data type varchar to varbinary(max) is not

allowed. Use the CONVERT function to run this query.DB-Lib error message 257, severity 16:\nGeneral

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值