本文介绍了错误关系不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从节点应用程序收到一个 [错误:关系原因不存在]
错误。该关系确实存在,我不确定是什么问题。
I am getting a [error: relation "causes" does not exist]
error from my node app. The relation does exist, I'm not sure what the problem is.
我创建的表是
CREATE TABLE causes (
cause_id bigint NOT NULL default nextval('causes_cause_id_seq'::regclass),
cause_name varchar(40) NOT NULL,
goal integer,
sponsor varchar(30),
organization varchar(30),
submitter varchar(30),
address varchar(34),
balance numeric
);
这是给出错误的查询:
client = pg.connect(connectionString, function(err, client, done){
if(err) console.log(err);
client.query('INSERT INTO causes (cause_name, goal, organization, sponsor, submitter) VALUES ($1,$2,$3,$4,$5) RETURNING *', r, function(err, result){
if(err) console.log(err);
});
});
推荐答案
在您的客户端之前。 query('INSERT ...')
调用,运行以下命令以确保您的关系在当前连接上可访问:
Directly before your client.query('INSERT...')
call, run the following to ensure that your relation is accessible on the current connection:
client.query('SELECT * FROM pg_catalog.pg_tables', function(err, result) {
console.log(result);
});
如果看不到原因
结果之间的关系,那么要么该关系不存在,要么是在其他用户下创建的。
If you don't see your causes
relation among the results, then either the relation doesn't exist, or it was created under a different user.
这篇关于错误关系不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!