denisenkom / pytds

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

Bulk Insert failing due to incorrect column types #84

Closed thihara closed 6 years ago

thihara commented 6 years ago

I was trying to use pytds to write some data to Azure SQL Datawarehouse.

The write operations failed and upon closer inspections it appears to be because pytds sets all types as NVARCHAR(4000)

We need to allow custom metadata (column definitions) to be passed along defining the proper types.

thihara commented 6 years ago

I have submitted a pull request for a new method named bulk_insert that accepts data as python objects directly.

The column definitions (metadata) will need to be provided manually since it doesn't look like there's a way to detect the column types from the description field. At least not for SQL Datawarehouse on Azure.