4 min readUpdated Mar 2, 2026

pg.adapter Integration Documentation

Overview

The pg.adapter is an integration module for Vantage that allows for Read-Only and controlled Write access to PostgreSQL databases. It implements a connection pool to manage database connections efficiently and ensures safe handling of operations through strict validation of SQL queries.

Purpose

The main purposes of the pg.adapter are:

How It Works

The pg.adapter utilizes the pg library to create a connection pool to a PostgreSQL database. It provides methods for:

Expected Data

The pg.adapter expects the following data for initialization:

These parameters are passed as part of an encryptedRecord object during the instantiation of the SQLAdapter class.

Settings

The following settings are used to configure the pg.adapter. Each one is explained in detail below:

1. Host

2. Port

3. Username

4. Password

5. Database Name

6. SSL

Use Cases & Examples

Use Case 1: Data Analysis

A data analyst needs to extract data from a PostgreSQL database for a specific reporting project. They can use the pg.adapter to query multiple tables without modifying the database structure.

Use Case 2: Dashboard Integration

A developer is looking to create a live dashboard that needs up-to-date data from a PostgreSQL database. They can use the pg.adapter to efficiently capture data for real-time visualizations without the risk of corrupting the underlying data.

Use Case 3: Compliance and Audit

A compliance officer needs to review database schemas and tables for audit purposes. Using the pg.adapter, they can introspect the database schema and retrieve metadata without the risk of executing unsafe queries.

Configuration Example

Use Case: Data Analysis

Scenario: A data analyst needs to perform read-only operations on the "sales_data" table.

Sample Configuration Data:

json
{
  "host": "localhost",
  "port": 5432,
  "username": "data_analyst",
  "password": "securepassword123",
  "databaseName": "sales_db",
  "ssl": false
}

Implementation Example:

javascript
const pgAdapter = new SQLAdapter({
  host: "localhost",
  port: 5432,
  username: "data_analyst",
  password: "securepassword123",
  databaseName: "sales_db",
  ssl: false,
});

// Testing the connection
pgAdapter.testConnection().then(isConnected => {
  if (isConnected) {
    console.log("Successfully connected to the database!");
    // Perform read operations
    pgAdapter.executeReadOnly("SELECT * FROM sales_data;")
      .then(data => console.log(data.rows))
      .catch(err => console.error(err));
  } else {
    console.error("Failed to connect to the database.");
  }
});

AI Integrations

Currently, the pg.adapter does not have any direct AI integrations. However, the data retrieved through this integration can be fed into AI models or analytics tools for further processing, forecasting, and data insights.

Billing Impacts

Using the pg.adapter incurs potential costs related to database connections and query executions. These costs depend on:

Users should consult their PostgreSQL service provider for detailed billing information based on their usage of the pg.adapter.