Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

redshift-query

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redshift-query

Library which allows you to query Redshift using parameterized SQL files and promises

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

redshift-query

Library which allows you to query Redshift using parameterized SQL files and promises.

Install

npm install redshift-query --save

Initialization:

connection is your Redshift connection info. queryPath is where your SQL files are located at.

const RedshiftQuery = require('redshift-query')

const redshift = new RedshiftQuery({
  connection: {
    user: 'super_cool_dev_person',
    database: 'rad_database',
    password: 'horse_battery_staple',
    port: 5439,
    host: 'rad_redshift'
  },
  queryPath: './sql'
})

API

redshift#queryByFile(queryFile, parametersObj)

Warning: Do not use raw user input as parameter input, it opens you up to SQL injection attacks.

redshift.queryByFile('count_unicorns.sql', { type: 'flying' })
  .then((stable) => {
    stable.rows.forEach((unicorn) => {
      console.log('Name: ', unicorn.name)
    })
  })

redshift#queryByString(queryString)

Warning: Do not use raw user input as parameter input, it opens you up to SQL injection attacks.

redshift.queryByString(`SELECT type, name FROM unicorns WHERE type='flying'`)
  .then((stable) => {
    stable.rows.forEach((unicorn) => {
      console.log('Name: ', unicorn.name)
    })
  })

SQL file example:

SELECT type, name
FROM unicorns
WHERE type='${type}'

Yep, nothing fancy. No need to make it a template string, just put a bunch of text in there (preferably Redshift-compliant SQL)

Keywords

redshift

FAQs

Package last updated on 16 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts