This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

planetscale-node
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

planetscale-node

This is the pre-release JavaScript client for connecting to PlanetScale.

Installation

$ npm install planetscale-node

Setup

This code uses the PlanetScale API to provision a TLS certificate, and then connects to the database. It uses Service Tokens for authentication, so you'll need to create one for the app:

~> pscale service-token create
  NAME           TOKEN
 -------------- ------------------------------------------
  nyprhd2z6bd3   [REDACTED]

~> pscale service-token add-access nyprhd2z6bd3 connect_production_branch --database [YOUR DB]
  DATABASE   ACCESSES
 ---------- ---------------------------
  [YOUR DB]       connect_production_branch

Usage

Set the following environment variables in your application.

export PLANETSCALE_TOKEN='[REDACTED]'
export PLANETSCALE_TOKEN_NAME='nyprhd2z6bd3'
export PLANETSCALE_ORG='[YOUR ORG]'
export PLANETSCALE_DB='[YOUR DB NAME]'
const { PSDB } = require('planetscale-node')
const conn = new PSDB('main')

async function main() {
  const [rows, fields] = await conn.query('select * from reminders')
  console.log(rows, fields)
}

main()

Using prepared statements

const { PSDB } = require('planetscale-node')
const conn = new PSDB('main')

async function main() {
  const [rows, fields] = await conn.execute('select * from reminders where id > ?', [10])
  console.log(rows, fields)
}

main()

Readme

Keywords

none

Package Sidebar

Install

npm i planetscale-node

Weekly Downloads

57

Version

0.3.0

License

ISC

Unpacked Size

19.6 kB

Total Files

5

Last publish

Collaborators

  • dbussink
  • dgraham
  • llibdude
  • nickvanw
  • no-itsbackpack