Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Here's my code, it's pretty much straight out of the docs:

var pg = require('pg');
var client = new pg.Client('postgres://localhost');
client.connect();
var dbName ='myDb'; 
var query = client.query('CREATE DATABASE $1', [dbName]);
query.on('error', console.log.bind(console));

Unfortunately, it fails:

{ [error: syntax error at or near "$1"]
  name: 'error',
  length: 84,
  severity: 'ERROR',
  code: '42601',
  detail: undefined,
  hint: undefined,
  position: '17',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  file: 'scan.l',
  line: '1006',
  routine: 'scanner_yyerror' }

It works without the use of the parameter. Does anyone know why?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.