Search code examples
robotframeworkpython-3.8database-testing

How to store a result of SQL query as String in python


I am using Robot framework in python and I am running below query:

${queryResults1}=  query  select count(*) from table

It gives me below result:

${queryResults2} = [(91,)]

How to convert above result as String?


Solution

  • The response format is a list of tuples - as can also be seen by the sample you've pasted. Thus get the 1st column of the first row (in python/Robot Framework the lists are 0-based), and pass that to Convert To String:

    ${the value as string}=    Convert To String    ${queryResults1[0][0]}