balderdashy/sails

error: column "temp" does not exist, hint: 'There is a column named "temp" in table "temp", but it cannot be referenced from this part of the query.',

Open

#7,007 opened on Jun 11, 2020

View on GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (22,778 stars) (1,953 forks)batch import
help wantedmore info pleaseorm

Description

var mqtt = require('mqtt') var client = mqtt.connect('mqtt://localhost') const Pool = require('pg'); const cs = 'postgres://postgres:Password@123@localhost:5432/temp'; const pool= new Pool.Client(cs); pool.connect();

temp=0 hum=0

client.on('connect', () => { client.subscribe('esp/dht/temperature',{qos:1}); console.log('client has subscribed Temp successfully'); client.subscribe('esp/dht/humidity',{qos:1}); console.log('client has subscribed humidity successfully');})

client.on('message', (topic, message) => { if (topic === 'esp/dht/temperature') { temp = message.toString(); }

if (topic === 'esp/dht/humidity') { hum = message.toString(); }
console.log('Temperature:-',temp,'Humidity:-',hum)

})

//const query= 'INSERT INTO temp(temp,hum) VALUES (temp,hum)'; pool.query( "INSERT INTO temp(temp,hum)VALUES(temp,hum)", (err, res) => { console.log(err, res); pool.end(); } );

returns error

{ error: column "temp" does not exist at Parser.parseErrorMessage (/root/psql/node_modules/pg-protocol/dist/parser.js:241:15) at Parser.handlePacket (/root/psql/node_modules/pg-protocol/dist/parser.js:89:29) at Parser.parse (/root/psql/node_modules/pg-protocol/dist/parser.js:41:38) at Socket.stream.on (/root/psql/node_modules/pg-protocol/dist/index.js:8:42) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:607:20) length: 210, name: 'error', severity: 'ERROR', code: '42703', detail: undefined, hint: 'There is a column named "temp" in table "temp", but it cannot be referenced from this part of the query.', position: '34', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'parse_relation.c', line: '3293', routine: 'errorMissingColumn' } undefined

Contributor guide