denisenkom / pytds

Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation
MIT License
192 stars 53 forks source link

Fix bulk inserting [n]varchar(max) values. #95

Closed LHCGreg closed 6 years ago

LHCGreg commented 6 years ago

Trying to bulk insert varchar(max) or nvarchar(max) values would give the following error:

While reading current row from host, a premature end-of-message was ncountered--an incoming data stream was interrupted when the server expected to see more data. The host program may have terminated. Ensure that you are using a supported client application programming interface (API).

I don't know why, but you have to send PLP_UNKNOWN instead of the actual length of the content you're sending for the initial length before sending any chunks.

Fixes #92

codecov[bot] commented 6 years ago

Codecov Report

Merging #95 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #95   +/-   ##
=======================================
  Coverage   94.02%   94.02%           
=======================================
  Files          26       26           
  Lines        7818     7818           
=======================================
  Hits         7351     7351           
  Misses        467      467
Impacted Files Coverage Δ
tests/connected_test.py 98.55% <ø> (ø) :arrow_up:
tests/unit_test.py 99.21% <ø> (ø) :arrow_up:
src/pytds/tds_types.py 92.97% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2878b5e...52fcbdb. Read the comment docs.

denisenkom commented 6 years ago

Looks good, thanks!