I am new to python, and am finding that my first attempt to connect via ODBC always fails with the error you see below, however the 2nd attempt, immediately afterwards, always succeeds, and does so pretty quickly. Any thoughts on why this might be? I would like to test to for a successful connection in a loop, like with a 'try' statement, but not sure how to do that. All suggestions appreciated.
Here is the test script I'm attempting to run. ( I just added the queryTimeout to see if it made a difference -- it didn't):
import teradata
udaExec=teradata.UdaExec()
with udaExec.connect("${dataSourceName}") as session:
for row in session.execute("SELECT max(calendar_dt) from myDB.myTableName", queryTimeout=120):
print(row)
######### first attempt results###############
bash-3.2$ python testConnection.py
Traceback (most recent call last):
File "testConnection.py", line 5, in <module>
with udaExec.connect("${dataSourceName}") as session:
File "/Applications/anaconda/lib/python3.5/site-packages/teradata/udaexec.py", line 172, in connect
**args))
File "/Applications/anaconda/lib/python3.5/site-packages/teradata/tdodbc.py", line 367, in __init__
checkStatus(rc, hDbc=self.hDbc, method="SQLDriverConnectW")
File "/Applications/anaconda/lib/python3.5/site-packages/teradata/tdodbc.py", line 199, in checkStatus
raise DatabaseError(i[2], u"[{}] {}".format(i[0], i[1]), i[0])
teradata.api.DatabaseError: (60, '[HYT00] [Teradata][Unix system error] 60 Socket error - No response received when attempting to connect to the Teradata server')
######## 2nd attempt results ############
bash-3.2$ python testConnection.py
Row 1: [2016-03-25]