Action has encountered operational database interface automation
table of Contents
1, install third-party libraries
2, installation pymysql
3, database operations
1, install third-party libraries
Use online installation: PIP install robotframework_databaselibrary -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-Host pypi.tuna.tsinghua.edu.cn
2, installation pymysql
Use the online installation Installation: PIP install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-Host pypi.tuna.tsinghua.edu.cn
3, database operations
Import library:
Create a connection:
Connect to database using custom params pymysql database='jpress', user='root', password='123456', host='localhost', port=3306
${q} query SELECT * FROM `jpress`.`jpress_user` WHERE `username` = 'root'
log ${q}
The first line: Connect the To the Using the Custom Database connecting the Params mysql, parameters database database = 'jpress', user = 'root', password = '123456', host = 'localhost', port = 3306
The second line: the query parameters to execute your sql statement, $ {q} execution result
In addition: 1, if a query returns there, like adding and deleting it does not, you can use another Execute Sql String, execute sql like: the Execute Sql String DELETE the FROM `jpress`.`jpress_user` the WHERE` id` = 44
2, complete disconnect database: the Disconnect the From Database
Scenario:
1, for example, to remove an entry, you can go to the data found in a deleted
2, for example, a new, lower database to check whether the operation was successful