尝试使用 node.js 'pg' 处理 postgres 大对象时出现 postgres 错误
Getting postgres error when trying to work with postgres large objects using node.js 'pg'
尝试使用 pg.Client.query()
执行 SELECT lo_creat(?)
我收到错误消息:
'syntax error at or near ")"'.
“节点”12.16.1,“pg”8.0.2,“PostgreSQL”12.0
const { Client } = require('pg');
...
const client = new Client({
host: <host>,
port: <port>,
database: <database>,
user: <user>,
password: <password>,
});
await client.connect();
await client.query("SET SCHEMA '<schema>'"); // everything is fine
await client.query('SELECT lo_creat(?)', [0x00060000]); // throws thw error here
...
尝试通过 pgAdmin4 在我的手动连接上执行完全相同的查询,它返回创建的 oid
.
时运行良好
非常感谢任何帮助,在此先感谢。
这里的问题是使用了错误的语法来传递参数。
应使用 </code> 而不是 <code>?
。
await client.query('SELECT lo_creat()', [0x00060000]);
工作正常。
尝试使用 pg.Client.query()
执行 SELECT lo_creat(?)
我收到错误消息:
'syntax error at or near ")"'.
“节点”12.16.1,“pg”8.0.2,“PostgreSQL”12.0
const { Client } = require('pg');
...
const client = new Client({
host: <host>,
port: <port>,
database: <database>,
user: <user>,
password: <password>,
});
await client.connect();
await client.query("SET SCHEMA '<schema>'"); // everything is fine
await client.query('SELECT lo_creat(?)', [0x00060000]); // throws thw error here
...
尝试通过 pgAdmin4 在我的手动连接上执行完全相同的查询,它返回创建的 oid
.
非常感谢任何帮助,在此先感谢。
这里的问题是使用了错误的语法来传递参数。
应使用</code> 而不是 <code>?
。
await client.query('SELECT lo_creat()', [0x00060000]);
工作正常。