gpt4 book ai didi

python - 使用 Python 中的 teradatasql 模块连接到 Teradata

转载 作者:行者123 更新时间:2023-12-04 13:37:25 25 4
gpt4 key购买 nike

我正在尝试使用 Python 中的 teradatasql 模块连接到 Teradata。代码在本地主机上运行良好,但一旦作为服务器代码的一部分部署在服务器上,它就会抛出错误。

编码:

import teradatasql
try:
host, username, password = 'hostname', 'username', '****'
session = teradatasql.connect(host=host, user=username, password=password, logmech="LDAP")

except Exception as e:
print(e)

我在服务器上遇到的错误:

[Version 16.20.0.60] [Session 0] [Teradata SQL Driver] Failure receiving Config Response message header↵ at gosqldriver/teradatasql. (*teradataConnection).makeDriverError TeradataConnection.go:1101↵ at gosqldriver/teradatasql. (*teradataConnection).sendAndReceive TeradataConnection.go:1397↵ at gosqldriver/teradatasql.newTeradataConnection TeradataConnection.go:180↵ at gosqldriver/teradatasql.(*teradataDriver). Open TeradataDriver.go:32↵ at database/sql.dsnConnector.Connect sql.go:600↵ at database/sql.(*DB).conn sql.go:1103↵ at database/sql. (*DB).Conn sql.go:1619↵ at main.goCreateConnection goside.go:275↵ at main. _cgoexpwrap_212fad278f55_goCreateConnection _cgo_gotypes.go:240↵ at runtime.call64 asm_amd64.s:574↵ at runtime.cgocallbackg1 cgocall.go:316↵ at runtime.cgocallbackg cgocall.go:194↵ at runtime.cgocallback_gofunc asm_amd64.s:826↵ at runtime.goexit asm_amd64.s:2361↵Caused by read tcp IP:PORT->IP:PORT: wsarecv: An existing connection was forcibly closed by the remote host

最佳答案

概述了此错误的根本原因 here通过 tomnolan:

The stack trace indicates that a TCP socket connection was made to the database, then the driver transmitted a Config Request message to the database, then the driver timed out waiting for a Config Response message from the database.

In other words, the driver thought that it had established a TCP socket connection, but the TCP socket connection was probably not fully successful, because a failure occurred on the initial message handshake between the driver and the database.

The most likely cause is that some kind of networking problem prevented the driver from properly connecting to the database.


我今天遇到了这个问题,并通过更改我的主机解决了它。我也在 VPN 上发现 DNS 中的实际主机名不起作用,但可用的 ALIAS 起作用了。例如在 Windows 上:
C:\WINDOWS\system32>nslookup MYDB-TEST # <-- works
Server: abcd.domain.com
Address: <OMITTED>
Name: MYDB.domain.com # <-- doesn't work
Address: <OMITTED>
Aliases: mydb-test.domain.com # <-- works
我承认这可能是一个特定的解决方案选项,可能不适用于所有人,但根据我的经验,问题的根源被确认为 TCP 连接问题。

关于python - 使用 Python 中的 teradatasql 模块连接到 Teradata,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60967811/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com