zillow / ctds

Python DB-API 2.0 library for MS SQL Server
MIT License
83 stars 12 forks source link

Bulk insert specify column names #38

Closed gizmo93 closed 5 years ago

gizmo93 commented 5 years ago

The BULK Insert feature is great, but at the moment it assumes, that all columns which exist inside the target table exist as a column inside the data we supply.

It would be great to have an option to specify the column names used for creating the INSERT statement.

joshuahlang commented 5 years ago

I have a change for version 1.9 which will allow passing sequences of dict mappings of column name -> column value to bulk_insert. If the column allows NULL, and is not present in the dict, NULL will be passed instead. I think this will support the use case you're asking for here?

gizmo93 commented 5 years ago

Jep, that would be an even better solution for the problem :-) 👍

joshuahlang commented 5 years ago

Added in 1.9.0