0

I am querying DB and want to validation my output. The result from DB is coming in the manner -> (('ABC',),) and I want to validate it with string 'ABC', but I am unable due to extra characters received in my db output .

Can anybody help me with how to remove extra characters that are coming as output from DB?

I tried using Evaluate function:

Evaluate   '(('ABC',),)'.replace('(',' ')   

I need result as just ABC.

1 Answer 1

3

Do not do that - treat the response as a string, and try to get you data out through string replace.

The response is an object - a list of tuples, it actually looks like this:

[('ABC',),]

Every tuple in the list is a response row; every member of the tuple is a column in that row.

To get the first column of the first row, you just address them (their indices start from 0):

${value}=    Set Variable    ${the response object}[0][0]

If for example the query returnes 3 rows, each with 2 columns:

[('ABC', 'DEF'), ('GHI', 'JKL'), ('MNO', 'PQR')]

, you'd get the 3rd row's (index: 2) 2nd column (index: 1) - the string 'PQR' - with this:

${value}=    Set Variable    ${the response object}[2][1]

Now I hope you understand why using string replace (over the string representation of a two-dimensional list) is not a good idea.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.