将文件加载到Informix数据库时从Pandas DataFrame.to_sql获取错误

时间:2019-07-16 19:17:27

标签: python pandas dataframe pyodbc informix

在Informix数据库上使用Pandas Dataframe的to_sql方法加载文件时遇到错误。我可以连接到Informix数据库并使用read_sql_query方法执行select查询,如下所示:

df = pd.read_sql_query(query,con)

但是下面的代码抛出错误,我不知道为什么:

con = pyodbc.connect(constr, autocommit=True) 
file ='/home/webload/rajesh.txt' 
df = pd.read_csv(file, sep="\t") 
pd.DataFrame.to_sql(name='customers', schema='informix', con=con, if_exists='append', index=False )

这是我收到的错误:

Traceback (most recent call last):
  File "connect1.py", line 42, in <module>
    pd.DataFrame.to_sql(name='customers', schema='informix',con=con, if_exists='append', index=False  )
TypeError: to_sql() missing 1 required positional argument: 'self'

0 个答案:

没有答案