1

I am trying to use this peace of code but in Python, but I get error that the recordset doesn't have attributes. I already have the connection, and all the other functions from OTA, but I can't get recordset to work.

import win32com.client, os 
tdc = win32com.client.Dispatch("TDApiOle80.TDConnection") 
tdc.InitConnection('*********') 
tdc.Login('alex_qc', 'Memetril01*') 
tdc.Connect('DEFAULT', 'QualityCenter_Demo') 
testInstanceF = tdc.TestFactory
aFilter = testInstanceF.Filter
aFilter.SetFilter("TS_TEST_ID", 2)
lst = testInstanceF.NewList(aFilter.Text)
test = lst.Item(1) 
print test.Name
oCmd = tdc.Command ####Is this the way to assign the object command?

oCmd.CommandText = "select * testcycl"####Is this the way to assign the ob?
oRS = oCmd.Execute####Is this the way to execute the command text?
print(oRS.FieldValue[1])
tdc.Logout()
Anthon
  • 69,918
  • 32
  • 186
  • 246

1 Answers1

0
td = win32com.client.Dispatch('TDApiOle80.TDConnection.1')
td.InitConnectionEx(qcServer)
td.Login(qcUser,qcPassword)
td.connect(qcDomain,qcProject)
if td.connected is True:
    print ("Connected to " + qcProject)
    cm = td.Command
    cm.CommandText = 'select * from bug'
    rec = cm.Execute()
    print(rec.RecordCount)
    print(rec.ColName(0))
    print(rec.FieldValue(1))
    td.Logout()