python3+robot 关键字封装(数据库例子)

*** Settings ***
Library           DatabaseLibrary
*** Keywords ***

queryDB
[Arguments] ${select_sql}
connect to database using custom params psycopg2 database='数据库名',user='数据库用户名',password='数据库用户密码',host='数据库的ip',port='连接数据库的端口号'
${queryResult} query ${select_sql}
[Return] ${queryResult}
*** Test Cases ***

#关键字引用
#后续直接用关键字名称+参数 即
#$后续的关键字获取传入该参数    queryDB    赋值后的参数

${selecttId} set variable select id from tablename where 条件=
    ${queryResult}  queryDB  ${selectId}
log ${queryResult}
${id} evaluate str('${queryResult[0][0]}')

log ${Id}
原文地址:https://www.cnblogs.com/zyy98877/p/12921294.html