使用SQLalchemy通过Python将Excel加载到SQL的数据类型错误将Excel加载到SQL
我正在尝试使用SQLalchemy通过Python将CSV文件加载到Oracle中。我通常会遇到错误“ cx_oracle.databaseerror:ora-00932:不一致的数据类型:预期日期clob”,并且本无法解决。
headers = ['LINE_START_DATE', 'LINE_END_DATE']
dtypes = {'LINE_START_DATE': 'str', 'LINE_END_DATE': 'str'}
parse_dates = ['LINE_START_DATE', 'LINE_END_DATE']
df = pd.read_csv(processpath+filename, sep=',',index_col=False, dtype=dtypes, names=headers, parse_dates=parse_dates)
engine = create_engine('oracle://'+username+':'+password+database)
df.to_sql(table, con=engine, if_exists = 'append', index=False)
日期列不仅仅是上面的两个列更多,但是一次只能进行一列即可尝试查找问题。有什么想法吗?
I am trying to load a CSV file into Oracle via Python using SQLAlchemy. I am routinely getting the error "cx_Oracle.DatabaseError: ORA-00932: inconsistent datatypes: expected DATE got CLOB" and have ben unable to solve.
headers = ['LINE_START_DATE', 'LINE_END_DATE']
dtypes = {'LINE_START_DATE': 'str', 'LINE_END_DATE': 'str'}
parse_dates = ['LINE_START_DATE', 'LINE_END_DATE']
df = pd.read_csv(processpath+filename, sep=',',index_col=False, dtype=dtypes, names=headers, parse_dates=parse_dates)
engine = create_engine('oracle://'+username+':'+password+database)
df.to_sql(table, con=engine, if_exists = 'append', index=False)
There are many more date columns than just the two above, but just going one column at a time to try to find the issue. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论