Skip to main content

DB::MYSQL

Perform MySql queries.

Prerequisite

Syntax

actions:
<action-id>:
type: DB::MYSQL
props:
query: <sql-query>

Properties

PropertyDescriptionType
<action-id>Unique identifier for the actionstring
typeType of the actionstring
propsProperties specific to this action. Refer to props section for more details.object

props

PropertyDescriptionTypeRequired
querySQL query to be executedstringtrue

Example

databaseTests.yml
actions:
insert:
type: DB::MYSQL
props:
query: "INSERT INTO links (url, name) VALUES('foo','bar');"
query:
type: DB::MYSQL
props:
query: "SELECT * FROM links;"

scripts:
validateMinOneRow: assert len(context["last_output"]["rows"]) == 1

tests:
sampleTest:
tasks:
- id: task1
resource: resources.mysqlDb
action: actions.insert
- id: task2
resource: resources.mysqlDb
action: actions.query
validate: scripts.validateMinOneRow

Output

📝 Note: Can be accessed using context["last_output"]

KeyDescriptionType
rowsList of result rows for the queryarray
timeTakenTime taken, in millisecondslong
errorError message, if any, produced by executing the querystring

Example

{
"timeTaken": 155,
"rows": [
{
"id": 1,
"name": "bar",
"url": "foo"
}
]
}