Registry / database / vega-transform-pg

vega-transform-pg

JSON →
library1.0.11jsnpmunverified

A Vega transform that executes SQL queries against PostgreSQL databases, enabling data fetching and transformation within Vega visualizations. Current stable version is 1.0.11, with an infrequent release cadence. Key differentiators include tight integration with Vega's reactive data pipeline and support for parameterized queries.

npm install vega-transform-pg
INSTALL
IMPORT
SIG · VEGA-TRANSFORM-PG
V
vega-transform-pg
databasejavascriptv1.0.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vegaTransformPg
✓ import vegaTransformPg from 'vega-transform-pg'
✗ const vegaTransformPg = require('vega-transform-pg')
ESM-only package; default export is the transform function.
VegaTransformPg
✓ import { VegaTransformPg } from 'vega-transform-pg'
If using TypeScript, this may be the type export.

Shows how to use the PostgreSQL transform in a Vega specification, including connection string and SQL query.

import vegaTransformPg from 'vega-transform-pg'; import { parse } from 'vega'; const spec = { $schema: 'https://vega.github.io/schema/vega/v5.json', data: [{ name: 'pgdata', transform: [{ type: 'pg', connection: 'postgresql://user:password@localhost:5432/mydb', sql: 'SELECT * FROM mytable' }] }], marks: [{ type: 'rect', from: { data: 'pgdata' } }] }; const runtime = parse(spec); // View creation and rendering...
Debug
Known issues
gotchaConnection string must be a valid PostgreSQL connection URI; invalid URIs cause silent failures.
fix
Use format: postgresql://user:password@host:port/database
affects: >=1.0.0
gotchaSQL injection risk if user input is concatenated into sql property; use parameterized queries.
fix
Pass parameters via 'params' property and use $1, $2 placeholders.
affects: >=1.0.0
breakingThe package only supports ESM; CommonJS require() will fail.
fix
Use import syntax or configure Node.js to handle ESM.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'vega-transform-pg'
Missing package installation
fix
npm install vega-transform-pg
TypeError: vegaTransformPg is not a function
Incorrect import (CommonJS require instead of ESM import)
fix
Use import vegaTransformPg from 'vega-transform-pg'
Upgrade
Version history
1.0.11latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client for Node.js
Agent activity
23 hits · last 30 days
node
18
Meta
1
OpenAI (training)
1
Resources
vega-transform-pg — npm install vega-transform-pg · libregistry