I am trying to load a Python Pandas dataset into an existing table in SQL Server database.
In SQL Server, the table contains three columns and types are below:
[account] [bigint] NULL,
[info] [nvarchar](500) NULL,
[start_date] [datetime] NULL
And this is my Pandas data:
account int64
info object
start_date datimetime64[ns]
When I was trying to run Python like:
for index, row in combined_df.iterrows():
values = (row.account, row.info, row.start_date)
cursor.execute("INSERT INTO my_table "
"(account, info, start_date "
"values(?, ?, ?)",
values
)
I get an error:
pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Conversion from variable or parameter type INT to target column type BIGINT is not supported. (102044) (SQLExecDirectW)')
Any ideas? I tried to convert the type to other ones but could not find any solution. Please give a help, many thanks!