Supercheck LogoSupercheck

Database Test

Query and validate database stateEdit

Run SQL queries and validate database state directly. Database tests connect to your databases securely and execute queries with result validation.

Create Test

  1. Go to Create → Database Test
  2. Write SQL query
  3. Add assertions
  4. Run and save

Database connections are defined inline in your script. Use getVariable() for connection details such as host, port, database, and user, and getSecret() for the password (see the example below). There is no separate connection picker in the UI.

Example

/**
 * PostgreSQL read health check.
 * 
 * Purpose:
 * - Verify database connectivity
 * - Check that a specific table exists and has expected columns
 * - Ensure read operations are functioning
 * 
 * Configuration:
 * - Requires 'pg' library (included in Supercheck runtime)
 * - Connection string must be configured via project variables
 * 
 * @requires pg - PostgreSQL client for Node.js
 */
import { expect, test } from '@playwright/test';
import { Pool } from 'pg';

const pool = new Pool({
  host: getVariable('DB_HOST'),
  port: parseInt(getVariable('DB_PORT') || '5432'),
  database: getVariable('DB_NAME'),
  user: getVariable('DB_USER'),
  password: getSecret('DB_PASSWORD'),
});

test.afterAll(async () => {
  await pool.end();
});

test.describe('database read health check', () => {
  test('users table returns expected columns', async () => {
    // Execute a simple SELECT query
    const result = await pool.query('SELECT id, email FROM users LIMIT 1');
    
    // Verify we got results and the schema matches expectations
    expect(result.rowCount).toBeGreaterThan(0);
    expect(result.rows[0]).toHaveProperty('email');
  });
});

Supported Databases

TypeDatabases
RelationalPostgreSQL, MySQL, SQL Server, MariaDB
CloudAmazon RDS, Azure SQL, Google Cloud SQL

Connection Methods

  • Direct — Connect to a publicly reachable database using credentials from Variables/Secrets.
  • Secrets — Store credentials securely with getSecret() instead of hardcoding them in the script.
  • Private networks — Reach databases inside a private network by supplying the connection string/endpoint that the execution environment can route to. Supercheck does not provide a built-in SSH-tunnel/bastion option; handle tunneled access at the network level.

Import the matching Node driver (pg, mysql2, mssql) at the top of your script — connection details come from Variables/Secrets, not a UI connection picker.

Common Assertions

AssertionExample
Row countCOUNT(*) > 0
Value checkstatus = 'active'
Not nullemail IS NOT NULL

On this page