1、安装databaselibrary、pymysql
通过cmd命令执行:pip install robotframework-databaselibrary
通过cmd命令执行:pip install robotframework-databaselibrary
2、导入库到robotframework中
编辑以下代码:
Connect To Database Using Custom Params | pymysql | database='数据名称', user='用户名', password='密码', host='IP地址', port=3306 | #mysql数据库默认端口是:3306 |
${data} | query | select * from sys_user where name='xiaoming' | #SQL语句 |
log | ${data} |
扩展:
-----数据库插入-------
Connect To Database Using Custom Params | pymysql | database='数据名称', user='用户名', password='密码', host='IP地址', port=3306 | |
${data} | Execute Sql String | INSERT INTO base_info (age, name, adr) VALUES (18, '小苏', '河南濮阳') | #插入操作 |
Disconnect From Database | #关闭连接 | ||
---END---