I get the following error during my SELECT query from PostgreSQL DB
ERROR: { error: relation "free_subnets" does not exist
at Connection.parseE (/home/ec2-user/environment/node_modules/pg/lib/connection.js:604:11)
at Connection.parseMessage (/home/ec2-user/environment/node_modules/pg/lib/connection.js:401:19)
at Socket.<anonymous> (/home/ec2-user/environment/node_modules/pg/lib/connection.js:121:22)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
name: 'error',
length: 103,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '15',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '874',
routine: 'parserOpenTable' }
If I use psql command and do a select there, it works.
\dt provides me the relation:
Schema | Name | Type | Owner
-------------+--------------+-------+----------
subnet_calc | free_subnets | table | postgres
Search_path has been set to: subnet_calc, public
I've created the table with user postgres, so I am the owner of the schema subnet_calc and the table free_subnets.
My dummy nodejs code is the following:
const pg = require('pg');
const cs = 'postgres://postgres:password@anydb.rds.amazonaws.com:5432/subnet_calculator';
const client = new pg.Client(cs);
client.connect();
client.query('SELECT * FROM subnet_calc.free_subnets', function(result) {
console.log(result);
});
What could be the issue?
Thanks for your help in advance!