Loprz / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

varbinary insert/update failure to SQL Server in Python 3 #33

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Code Snippet:

cur.execute("create table TEST ( name varchar(30), record varbinary(max) )")
cur.commit()

data = bytearray()
for i in range(10):
    for b in range(256):
        data.append(b)
        print(len(data))
        cur.execute("insert into TEST values (?, ?)", ('foo' + str(i*256+b), data))

Code works fine running in 2.7, but fails in 3.3:
pypyodbc.DataError: ('22001', '[22001] [Microsoft][SQL Server Native Client 
11.0]String data, right truncation')

Running on Win7 with 64bit python against SQL Server 2012.
Problem was originally discovered when trying to store gzip data blobs in a 
varbinary(max) column.

Original issue reported on code.google.com by adamson....@gmail.com on 11 Jan 2014 at 6:19

GoogleCodeExporter commented 8 years ago
Attached is the new release should fix your problem. Will be released very 
soon. Please see if that works for you.

Original comment by jiangwen...@gmail.com on 12 Feb 2014 at 2:54

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 12 Feb 2014 at 2:54

GoogleCodeExporter commented 8 years ago
This corrects the problem.

Original comment by adamson....@gmail.com on 13 Feb 2014 at 3:32

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 15 Feb 2014 at 6:28