Reputation: 1054
I've a script using RobotFramework that makes a lot of database tests. Currently, I am trying to add a new test case that executes a query test from another Python script (called raw_data.py). The raw_data.py is very simple and it only have this code:
query_begin = """SELECT *
FROM my_Table"""
def get_queries_list(query):
result = query.replace('\n','').strip()
return result
query_result = get_queries_list(query_begin)
print(query_result)
So what I want to do is to execute the result (the query) from the previous script using robotframework:
*** Settings ***
Library DatabaseLibrary
Library OperatingSystem
Library raw_data.py
Suite Setup Connect To Database pymysql ${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort}
Suite Teardown Disconnect From Database
*** Variables ***
${DBName} myDB
${DBUser} user
${DBPass} pass
${DBHost} hostname
${DBPort} port
${Query} 'SELECT * FROM DEV.personal_tasks'
*** Test Cases ***
Compare the target data with the source data
${output}= Execute SQL String get_queries_list(query)
log to console ${output}
should be equal as strings ${output} 10
But it gives me the following error:
No keyword with name 'Execute SQL String get_queries_list(${Query})' found.
However, the keyword 'Execute SQL String' already exists... what I am doing wrong?
Thanks in advance!!
Upvotes: 1
Views: 744
Reputation: 8352
I think you're missing at least 2 spaces between Execute SQL String
and get_queries_list(query)
so it evaluates it as a whole, which will then fail and return the error that no such keyword exists.
EDIT:
You also need to save the query into a variable that you later pass to Execute SQL String
:
${query}= get_queries_list(query)
Execute SQL String ${query}
Upvotes: 1