0

Doing a database query that returns multiple rows...

${visits_for_this_patient}=  Select from Database
...  Select to_char(visit_date, 'YYYY-MM-DD') from patient_visits where patient_id=${patient_id} order by visit_date
${list_of_visits_for_this_patient}=  create list  ${visits_for_this_patient}
Row Count Should Be Equal To X
...  Select * from patient_visits where patient_id=${patient_id}
...  ${expected_number_of_patients_for_this_visit}
...  ${SPONSOR_NAME}

How can i take a specific row's string value back without the padding? Im getting like

(b'2017-03-03',)

when i try ${visits_for_this_patient[0]}

1 Answer 1

2

You have to go one level deeper - the return value of а db query is a list of tuples (that's how the underlying python modules return the data).

E.g. it looks like this:

[(b'2017-03-03',)]

When you call ${visits_for_this_patient[0]}, you get the 1st member of the list - a tuple (what you saw yourself). To get the actual value, just get that value's first member (the 1st member of the tuple); so simply:

${visits_for_this_patient[0][0]}

The end value of that should be 2017-03-03 (as a string).

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.