简体   繁体   English

需要帮助了解 teradata 中的错误

[英]Need help understanding error in teradata

When running this query for some reason I always get not valid row handles error and I'm not really sure what it means.出于某种原因运行此查询时,我总是得到无效的行句柄错误,我不确定这意味着什么。 I've trying to do a python connection to teradata and print out the results of the queried data.我正在尝试与 teradata 建立 python 连接并打印出查询数据的结果。

import teradata
import teradatasql

with teradatasql.connect(host='PPTT', user='**', password='***', logmech='LDAP') as connection:
    connection.autocommit = True
    crsr = connection.cursor() 
    sql_command="""SELECT SOURCE_ORDER_NUMBER
    FROM DL_DB.BV_BO
    WHERE TRANS_TYPE='AR'
    """
    crsr.execute(sql_command) 

result = crsr.fetchall()

---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
<ipython-input-26-be601f4ff898> in <module>
----> 1 result = crsr.fetchall()

//anaconda3/lib/python3.7/site-packages/teradatasql/__init__.py in fetchall(self)
    921         try:
    922             rows = []
--> 923             for row in self:
    924                 rows.append(row)
    925 

//anaconda3/lib/python3.7/site-packages/teradatasql/__init__.py in __next__(self)
    991                     sErr = ctypes.string_at (pcError).decode ('utf-8')
    992                     goside.goFreePointer (self.connection.uLog, pcError)
--> 993                     raise OperationalError (sErr)
    994 
    995                 if pcColumnValues:

OperationalError: 6 is not a valid rows handle

Indentation matters in Python. Python 中的缩进很重要。 Try it this way试试这个方法

import teradatasql

with teradatasql.connect(host='PPTT', user='**', password='***', logmech='LDAP') as connection:
    connection.autocommit = True
    crsr = connection.cursor() 
    sql_command="""SELECT SOURCE_ORDER_NUMBER
    FROM DL_DB.BV_BO
    WHERE TRANS_TYPE='AR'
    """
    crsr.execute(sql_command) 

    result = crsr.fetchall()
...

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

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