I want to send parameters securly with postgresql to prevent sql injections.
if I send the parameter I will get this error Message: There is no Parameter $1
what do I am wrong?
'use strict';
const { Pool } = require('pg');
const pool = new Pool({
user: 'postgres',
host: '127.0.0.1',
database: 'TEST',
password: 'xxxx',
port: 4551,
});
const Query = async query => {
try {
await pool.connect();
const res = await pool.query('SELECT email FROM client WHERE email = $1', ["[email protected]"]);
console.log(res.rows[0]);
await pool.end();
} catch(e) {
return e;
}
};
module.exports = Query;
€: And should I use client or pool ?
question from:
https://stackoverflow.com/questions/65650614/nodejs-postgresql-send-secure-parameters-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…