I am using python (3.4.3) to ODBC to a Teradata database, (rather new to this) I am wondering (if possible) to reference values of rows by their field name as i am looping through them instead of by their list index. (in case i change my tables) Much like a record set in VBA with the ! syntax (recordset!FIELD_NAME)
If i run this code,
udaExec = teradata.UdaExec (appName="HelloWorld", version="1.0", logConsole=False)
session = udaExec.connect(method="odbc", dsn="TEST")
cursor = session.cursor()
rows = list(cursor.execute("SELECT TOP 1 * FROM RES_TBL"))
print(rows)
My output is: [<teradata.util.Row object at 0x000000000402D080>]
I eventually was able to store each row as string in a list so i could see them\ mess with them, but i feel like thats a bad idea for larger data sets. I am sorry if this is not a good question, but anything helps!!
my full code currently is:
import teradata
import pyodbc
import json
udaExec = teradata.UdaExec (appName="HelloWorld", version="1.0", logConsole=False)
session = udaExec.connect(method="odbc", dsn="TEST")
cursor = session.cursor()
rows = list(cursor.execute("SELECT TOP 1 * FROM RES_TBL"))
print(rows)
for row in session.execute("SELECT TOP 1 * FROM RES_TBL"):
testlist = []
testlist.append(str(row))
print(testlist)