Reputation: 39
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.
Upvotes: 0
Views: 213
Reputation: 20067
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.
Upvotes: 3