【发布时间】:2020-12-18 18:15:37
【问题描述】:
我正在尝试将 df 从 pythhon 上传到 sql server
步骤:
- 从 excel (xlsx) 导入的文件- 确定
- sqlalchemy 引擎-好的
错误:
SystemError:
from sqlalchemy import create_engine
import urllib
import pandas as pd
df.to_sql('table_name', con=engine, if_exists='replace', index=False)
df.info() 给出:
col1 5490 non-null int64
col2 5414 non-null object
col3 5490 non-null object
col4 5490 non-null object
col5 3921 non-null object
col6 5490 non-null object
col7 5490 non-null int64
col8 5490 non-null object
col9 5490 non-null object
col10 5490 non-null object
在sql表中,列类型为[int]和[varchar](max)
错误回溯 TypeError: 预期字节,str 找到
【问题讨论】:
-
粘贴整个错误堆栈跟踪。
标签: python pandas sqlalchemy pyodbc