DB::MYSQL
Perform MySql queries.
Prerequisite
Syntax
actions:
<action-id>:
type: DB::MYSQL
props:
query: <sql-query>
Properties
Property | Description | Type |
---|---|---|
<action-id> | Unique identifier for the action | string |
type | Type of the action | string |
props | Properties specific to this action. Refer to props section for more details. | object |
props
Property | Description | Type | Required |
---|---|---|---|
query | SQL query to be executed | string | true |
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:
- resource: resources.mysqlDb
action: actions.insert
- resource: resources.mysqlDb
action: actions.query
validate: scripts.validateMinOneRow
Output
📝 Note: Can be accessed using context["last_output"]
Key | Description | Type |
---|---|---|
rows | List of result rows for the query | array |
timeTaken | Time taken, in milliseconds | long |
error | Error message, if any, produced by executing the query | string |
Example
{
"timeTaken": 155,
"rows": [
{
"id": 1,
"name": "bar",
"url": "foo"
}
]
}