我尝试将 python 数据框导入 SQL 服务器上的数据库。我收到了这样的错误:
$ python mssql_insert.py
Traceback (most recent call last):
File "src\pymssql.pyx", line 448, in pymssql.Cursor.execute
File "src\_mssql.pyx", line 1064, in _mssql.MSSQLConnection.execute_query
File "src\_mssql.pyx", line 1095, in _mssql.MSSQLConnection.execute_query
File "src\_mssql.pyx", line 1228, in _mssql.MSSQLConnection.format_and_run_query
File "src\_mssql.pyx", line 1639, in _mssql.check_cancel_and_raise
File "src\_mssql.pyx", line 1683, in _mssql.maybe_raise_MSSQLDatabaseException
_mssql.MSSQLDatabaseException: (245, b"Conversion failed when converting the varchar value 'None' to data type int.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\XZHANGA\AppData\Local\Programs\Python\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1246, in _execute_context
cursor, statement, parameters, context
File "C:\Users\XZHANGA\AppData\Local\Programs\Python\Python36\lib\site-packages\sqlalchemy\engine\default.py", line 581, in do_execute
cursor.execute(statement, parameters)
File "src\pymssql.pyx", line 468, in pymssql.Cursor.execute
pymssql.OperationalError: (245, b"Conversion failed when converting the varchar value 'None' to data type int.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n")
它提到不能将“None”值导入SQL数据库(我记得它绝对可以)。
有人能在这里找到问题吗?