{"id":44102,"library":"vega-transform-pg","title":"vega-transform-pg","description":"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.","status":"active","version":"1.0.11","language":"javascript","source_language":"en","source_url":"https://github.com/heavyairship/vega-transform-pg","tags":["javascript","vega","transform","postgres"],"install":[{"cmd":"npm install vega-transform-pg","lang":"bash","label":"npm"},{"cmd":"yarn add vega-transform-pg","lang":"bash","label":"yarn"},{"cmd":"pnpm add vega-transform-pg","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostgreSQL client for Node.js","package":"pg","optional":false}],"imports":[{"note":"ESM-only package; default export is the transform function.","wrong":"const vegaTransformPg = require('vega-transform-pg')","symbol":"vegaTransformPg","correct":"import vegaTransformPg from 'vega-transform-pg'"},{"note":"If using TypeScript, this may be the type export.","symbol":"VegaTransformPg","correct":"import { VegaTransformPg } from 'vega-transform-pg'"}],"quickstart":{"code":"import vegaTransformPg from 'vega-transform-pg';\nimport { parse } from 'vega';\n\nconst spec = {\n  $schema: 'https://vega.github.io/schema/vega/v5.json',\n  data: [{\n    name: 'pgdata',\n    transform: [{\n      type: 'pg',\n      connection: 'postgresql://user:password@localhost:5432/mydb',\n      sql: 'SELECT * FROM mytable'\n    }]\n  }],\n  marks: [{ type: 'rect', from: { data: 'pgdata' } }]\n};\n\nconst runtime = parse(spec);\n// View creation and rendering...","lang":"typescript","description":"Shows how to use the PostgreSQL transform in a Vega specification, including connection string and SQL query."},"warnings":[{"fix":"Use format: postgresql://user:password@host:port/database","message":"Connection string must be a valid PostgreSQL connection URI; invalid URIs cause silent failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass parameters via 'params' property and use $1, $2 placeholders.","message":"SQL injection risk if user input is concatenated into sql property; use parameterized queries.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import syntax or configure Node.js to handle ESM.","message":"The package only supports ESM; CommonJS require() will fail.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.11':27 'cadenc':32 'current':23 'data':16,42 'databas':14 'differenti':34 'enabl':15 'execut':9 'fetch':17 'includ':35 'infrequ':30 'integr':37 'javascript':49 'key':33 'parameter':47 'pg':4 'pipelin':43 'postgr':52 'postgresql':13 'queri':11,48 'reactiv':41 'releas':31 'sql':10 'stabl':24 'support':45 'tight':36 'transform':3,7,19,51 'vega':2,6,21,39,50 'vega-transform-pg':1 'version':25 'visual':22 'within':20","created_at":"2026-06-05T17:02:59.334093+00:00","updated_at":"2026-06-05T17:02:59.334093+00:00","problems":[{"fix":"npm install vega-transform-pg","cause":"Missing package installation","error":"Error: Cannot find module 'vega-transform-pg'"},{"fix":"Use import vegaTransformPg from 'vega-transform-pg'","cause":"Incorrect import (CommonJS require instead of ESM import)","error":"TypeError: vegaTransformPg is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/heavyairship/vega-transform-pg#readme","github":"https://github.com/heavyairship/vega-transform-pg","docs":null,"changelog":null,"pypi":null,"npm":"vega-transform-pg","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}