我试图从Pythhon上传一个DF到sql server。
steps:
error: SystemError: <class 'pyodbc.ProgrammingError'> returned a result with an error set. expected bytes, str found
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()
gives:
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