chornbeak / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Bulk insert fails, but no error thrown #401

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Posted this to the pyodbc group 
(https://groups.google.com/forum/#!topic/pyodbc/22gz4v64ZCw) then to 
stackoverflow 
(http://stackoverflow.com/questions/30758331/pyodbc-mssql-bulk-insert-fails-but-
no-error-thrown) but have received no answer so far. 

What steps will reproduce the problem?
1. Create a table with a floating point column [A]
2. Bulk insert a file with the string 'NaN' instead of a floating point number 
[B]

What is the expected output? What do you see instead?

Expected output is an error because it should not be possible to insert a 
string in a floating point column. 
Instead, no error is thrown even though the bulk insert halts (and silently 
fails). You will see that the first row from the file (the number 1.1)is 
inserted

Note: When executing through MSSQL server studio I see an error as expected. 
The error is:

Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the 
specified codepage) for row 2, column 1 (SomeNum).
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The 
provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

What version of the product are you using? On what operating system?

Python 2.7.2 on Windows 7, pyodbc version 2.1.8, sqlalchemy version 0.7.6

Please provide any additional information below.

[A]
CREATE TABLE TestBulkInsert (SomeNum FLOAT NOT NULL)

[B]
BULK INSERT MyDBName..testbulkinsert FROM 'see_attached_file' WITH 
(FIELDTERMINATOR= ',',ROWTERMINATOR= 
'\n',FIRE_TRIGGERS,CHECK_CONSTRAINTS,MAXERRORS= 0,BATCHSIZE= 1);

Original issue reported on code.google.com by sylveste...@gmail.com on 30 Jun 2015 at 8:04

Attachments:

GoogleCodeExporter commented 8 years ago
Forgot to mention that even though 1.1 (the first row) is inserted, 1.234 (the 
last row) is not. 

Original comment by sylveste...@gmail.com on 30 Jun 2015 at 8:16