so I psql'd and created table users;
CREATE TABLE users (
id integer NOT NULL,
username text
);
I am able to grab rows by doing SELECT * FROM users;
However, when I use node.js with the library module pg to make calls I get the infamous relation does not exist.
const createQuery = {text: "INSERT INTO users(id, username) VALUES($1)",values: values}
const { rows } = await db.query(createQuery);
I wasn't running into this issue before a complete server migration.
There can two possible reasons for this situation:
CREATE TABLE myschema.users (...), similarly, CREATE TABLE myschema.users. If the schema name is not specified, PostgreSql will use the defualt schema, usually it's public. To check your which schema does your relation belongs to run this query, SELECT table_schema, table_name FROM information_schema.tables WHERE table_name = 'users'.SELECT current_database() and SELECT inet_server_addr() queries, just in case if you have connected to wrong database/host.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With