今天很郁闷,pymssql 出问题了 Text 字段不能超过4K(4096)个字符
pymssql 使用一段时间了, 因为没有使用太复杂的语句,一直还比较正常,但是今天在读取一些较大文本时出现了问题,只获取了部分文本,数据被强行截断了。
简单计算了一下,字段不能超过4096个字符,也就是4K。
select convert(varchar(50),guid) as guid, convert(text,content) as content from news
Google Baidu 了一把,据说是 SET TEXTSIZE 65536 就可以了,但是我试过不行,只好到 官方网站 上看
important doc update: documented that with the technology pymssql currently uses (DB Library for C), it is not possible to read or write BLOBs longer than 4096 bytes,
varchar
andnvarchar
data is limited to 255 characters, and longer strings are silently trimmed.
This is known limitation of TDS protocol. A workaround is toCAST
orCONVERT
that row or expression totext
data type, which is capable of returning 4000 characters.
貌似说 pymssql 使用 DB Library for C ,读取比4K 大的数据是不可能的, 哎,啥也别说了,准备换吧。