zillow / ctds

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

Bulk insert json error #47

Closed kumaar449 closed 5 years ago

kumaar449 commented 5 years ago

I am using ctds to do bulk insert where I get json array of records and I pass the json array to bulk-insert I verified all the columns are matching between json and table I get error .

Column out of range error, with json we cannot do ctds SQL param also , any suggestion here is greatly appreciated.

kumaar449 commented 5 years ago

My sample : connection.bulk_insert( 'Table1', ( Json array here { "name":"kumar"}

    )
)

In table all columns are varchar

joshuahlang commented 5 years ago

Are you using ctds version 1.9.0? What is the exact Python code that is raising the error? What you have above is not valid Python.

kumaar449 commented 5 years ago

i am using ctds - 1.8.0. i just added sample code which i used : row_count = connection.bulk_insert( tablename, [ (content) ] )

here content is a JSON object with set of values matching table columns.

kumaar449 commented 5 years ago

DatabaseError: Column number out of range

row_count = connection.bulk_insert( tablename, [ (content) ] )

joshuahlang commented 5 years ago

ctds 1.8 doesn't support passing row data to bulk_insert as dict objects. You'll need to upgrade to ctds 1.9