简体   繁体   English

使用 SQLAlchemy 将 dataframe 推送到 db2 数据库时出错

[英]Error in pushing dataframe to db2 Database using SQLAlchemy

I have a dataframe that is of shape 3200 x 8 .我有一个形状为3200 x 8的 dataframe 。 I am trying to push it to IBM's DB2 Database using sqlalchemy.我正在尝试使用 sqlalchemy 将其推送到 IBM 的 DB2 数据库。 One of the columns have text in it which is of variable length, think of it as English sentences/comments with emojis in it, and some other columns containing some other data types.其中一列包含可变长度的文本,将其视为带有表情符号的英语句子/评论,以及包含其他一些数据类型的其他列。 All in all, consider the dataframe to be of a large size.总而言之,考虑到 dataframe 的尺寸很大。

FYI, I've configured the engine and with small chunk of data it seems fine.仅供参考,我已经配置了引擎,并且使用少量数据看起来还不错。

When I do,当我做,

df.to_sql(name="my_table", con=db2_engine,index=False,if_exists='append')

I get an error,我得到一个错误,

DatabaseError: ibm_db_dbi::DatabaseError: Exception('SQLRowCount failed: [IBM][CLI Driver] CLI0125E Function sequence error. SQLSTATE=HY010 SQLCODE=-99999')

I tried the chunk option for to_sql but to no avail.我尝试了 to_sql 的块选项,但无济于事。

How do I fix this error?如何修复此错误?

Edit:编辑:

This is the output of my pip freeze这是我的pip freeze的 output

cachetools==4.1.0
certifi==2020.4.5.1
chardet==3.0.4
emoji==0.5.4
google-api-core==1.17.0
google-api-python-client==1.8.2
google-auth==1.14.2
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.1
googleapis-common-protos==1.51.0
httplib2==0.17.3
idna==2.9
langdetect==1.0.8
oauthlib==3.1.0
protobuf==3.11.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pytz==2020.1
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.0
six==1.14.0
uritemplate==3.0.1
urllib3==1.25.9

Had today the same problem (reason why I found this link).今天有同样的问题(我找到这个链接的原因)。

The problem appeared to be as @mao suggested there was a content that db2 was rejecting, in my instance I had a column which contained some integers and some empty strings, confusing the SQL interpreter on the actual data type to be used (int or strings).问题似乎是@mao建议有一个内容被db2拒绝,在我的例子中,我有一列包含一些整数和一些空字符串,混淆了SQL解释器对要使用的实际数据类型(int或字符串) )。

Solution: changed all values within the column to a string data type and it worked.解决方案:将列中的所有值更改为字符串数据类型并且它工作。

Source on error: https://www.sqlerror.de/db2_sql_error_-804_sqlstate_07002.html错误来源: https://www.sqlerror.de/db2_sql_error_-804_sqlstate_07002.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM