Closed j1yuan closed 1 year ago
Here is everything that I can see on the terminal screen:
[s_dev_infsvc@devbisedge01 tmp]$ ./test_df_bulk.py
Connected.
Created cursor.
df: BrandId LenderId NameKey ... EndDate EnrollmentCode RecordJson
0 4 5 A1 ... 2022-09-21 09:15:40.1700000 AE {'CAMPAIGNDESCR': 'EOSDirectMail1', 'ENROLLMEN...
1 4 5 B1 ... 2022-09-22 09:15:40.1700000 BE {'CAMPAIGNDESCR': 'EOSDirectMail2', 'ENROLLMEN...
2 4 5 C1 ... 2022-09-23 09:15:40.1700000 CE {'CAMPAIGNDESCR': 'EOSDirectMail3', 'ENROLLMEN...
3 4 5 D1 ... 2022-09-24 09:15:40.1700000 DE {'CAMPAIGNDESCR': 'EOSDirectMail4', 'ENROLLMEN...
4 4 5 E1 ... 2022-09-25 09:15:40.1700000 EE {'CAMPAIGNDESCR': 'EOSDirectMail5', 'ENROLLMEN...
[5 rows x 8 columns]
df columns: Index(['BrandId', 'LenderId', 'NameKey', 'NameKey2', 'StartDate', 'EndDate',
'EnrollmentCode', 'RecordJson'],
dtype='object')
file_path: /tmp/bulk_test.csv
created file: /tmp/bulk_test.csv
Traceback (most recent call last):
File "./test_df_bulk.py", line 45, in <module>
cur.copy_to(file_path, 'PrescreenRecords_Stage', sep='|', columns=('BrandId','LenderId','NameKey','NameKey2','StartDate','EndDate','EnrollmentCode','RecordJson'))
File "/home/s_dev_infsvc/.local/lib/python3.6/site-packages/pytds/__init__.py", line 1003, in copy_to
self._session.submit_bulk(metadata, rows)
File "/home/s_dev_infsvc/.local/lib/python3.6/site-packages/pytds/tds.py", line 1090, in submit_bulk
serializers[i].write(w, row[i])
IndexError: list index out of range
I realized that I need to create Column objects and use them in the columns parameter. I'll close this issue.
I am using the latest version (1.11.0).
The target table is created by:
In my code, I create the CSV file on the flight, then, use the copy_to() function to load.
It is run on a linux server, and the error message is
IndexError: list index out of range
I wonder if someone can help me?