在python中使用TeradasQL模块将数据上载到Teradata时出错

2024-06-16 09:22:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用python中的Teradasaql模块将数据上传到Teradata中的表中,但出现以下错误:

A failure occurred while executing rows 1 through 2 of a batch request...Caused by [Version 17.0.0.8] [Session 21731976] [Teradata Database] [Error 3939] 
There is a mismatch between the number of parameters specified and the number of parameters required.

以下是我正在使用的代码:

import teradatasql

listbatch = x.values.tolist()

with teradatasql.connect ('{"host":"whomooz","user":"guest","password":"please"}') as con:
    with con.cursor () as cur:
        cur.executemany ("insert into mytableinTeradata  ('?,?,?')", listbatch)

这就是listbatch的外观

[[0, 'Rep Entered', '8cfc12c9-000d3a8fc913'],
 [0, 'Rep Entered', '699831ad-0fa60249f33e']]

从数据类型来看,它们似乎匹配:

对于listbatch:

TEST_IND               int64
SOURCE_LABEL           object
OPPORTUNITYID          object
dtype: object

对于MyTableData:

TEST_IND                        I 
SOURCE_LABEL                    CV
OPPORTUNITYID                   CV

我以前能够在不同的项目中使用相同的代码,没有任何问题。我不确定这里有什么不同。你有没有想过这个错误意味着什么以及如何解决它


Tags: ofthe代码numberobjectas错误with