Ask a Question

Python - Using ADO and RecordSet in testcomplete scripts

SOLVED
dwong_smartbear
Occasional Contributor

Re: Python - Using ADO and RecordSet in testcomplete scripts

@tristaanogre I've narrowed down the problem with the "SELECT *...." statement.  So, it turns out if any of the columns in my TT_ADJUST table is of type TIMESTAMP(6), that exception will be thrown.

The "solution" is to do a TO_CHAR conversion on a timestamp field, i.e. 'SELECT TO_CHAR(SENTDATE, 'YYYY-MM-DD') FROM ....'

However, that means I can't blindly use "SELECT *" on any table, which is what I'd ideally want.  Is there another way to set a connection, cursor or recordset property to allow this conversion to happen automatically? From what I've found by searching, it was mentioned in https://docs.oracle.com/cd/E47955_01/win.121/e18594/using.htm that using a CursorLocation property was needed.  So I tried the following, but it still gave the same error on SELECT *:

 

def test_oracle():
  conn = ADO.CreateADOConnection()
  conn_str = "Driver={%s};Server=%s;Uid=%s;Pwd=%s;" % (
                                Common.conf['GLOBAL.DB.DRIVER'],
                                Common.conf['GLOBAL.DB.SERVER'],
                                Common.conf['GLOBAL.DB.UID'],
                                Common.conf['GLOBAL.DB.PWD'])
  Log.Message("conn_str: " + conn_str)
  conn.ConnectionString = conn_str
  conn.LoginPrompt = False
  conn.Open()
  rec_set = ADO.CreateRecordset()
  rec_set.CursorLocation = 2
  rec_set = conn.Execute_("SELECT * FROM ADMD.TT_ADJUST WHERE ETD in ('AZ1014')")
cunderw
Community Hero

Re: Python - Using ADO and RecordSet in testcomplete scripts

What type of DB is this and what driver are you using? This definitely sounds like a driver issue rather than TC itself as it just calls out to the ADO. I have seen some weird issues with DBs and differing driver versions. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
dwong_smartbear
Occasional Contributor

Re: Python - Using ADO and RecordSet in testcomplete scripts

Based on my previous response, I agree that this is likely an issue with drivers for Oracle 11i DB.  The driver I'm using is 'Microsoft ODBC for Oracle'.

My further research has shown that the TO_CHAR() method on any timestamp field is used in many examples I've come across so far.  I just wish there was a more generic solution so that I can safely use "SELECT *" without worrying about the field types.

cancel
Showing results for 
Search instead for 
Did you mean: