Skip to main content

DB::POSTGRESQL

Perform PostGresql queries.

Syntax

actions:
<action-id>:
type: DB::POSTGRESQL
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::POSTGRESQL
props:
query: "INSERT INTO links (url, name) VALUES('foo','bar');"
query:
type: DB::POSTGRESQL
props:
query: "SELECT * FROM links;"

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

tests:
sampleTest:
tasks:
- resource: resources.postgresDb
action: actions.insert
- resource: resources.postgresDb
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"
}
]
}