byte string too long error in Python using pypyodbc 1.3.4

被刻印的时光 ゝ 提交于 2019-12-12 15:34:39

问题


Getting byte string too long error while saving more than 127 characters in Unix environment while using pypyodbc 1.3.4 and Python Anaconda 3.5.

Gone through this link Byte string too long PyPyOdbc and applied the fix as stated but still issue persists.

I am trying to save more than 127 characters. Database is MS Sql Server. Column type is varchar MAX or nvarchar MAX (I tried with both).

Saving 127 orless than 127 characters is fine and working.

Thanks


回答1:


I ran into the same issue with NVARCHAR(MAX) on MS SQL and pypyodbc 1.3.4:

    cursor.execute("insert into mytable (my_nvarchar_max_column) values (?)", "some long text here......")

fails with 'byte string too long' error.

Passing the string as a byte array works:

cursor.execute("insert into mytable (my_nvarchar_max_column) values (?)", 
"some long text here......".encode('utf8'))


来源:https://stackoverflow.com/questions/50056878/byte-string-too-long-error-in-python-using-pypyodbc-1-3-4

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