Getting data from postgres db

i am new and trying my hand on n8n,

Issues:

i have issue trying to get data out from the postgres database
i have connected my n8n postgres node to my postgres (in docker) with the credentails.

Setup:

my table name in postgres is “student_object” and its fields are student_id, name, hobby, age
where student_id is string, name is string, hobby is string, age is integer. They are just created in the table based on standard postgres sql statement.

Action:
my query is : select * from student_object;
i also tried : select student_id from student_object;

When i perform query by filling the “query” field in the parameter, the result return is “Entries exist but they do not contain any JSON data.”

Does the table in postgres need to be saved in json to work with n8n? What if my data is a flat one in postgres saved using standard postgres method ?

Please advise. thank you

Hey @lchunleo!

Are you running Postgres in a Docker container? If yes, is it accessible outside Docker?

You don’t need to store the data in JSON. The node will return the data from the table, no matter if contains JSON or not.

Yes , it is accessible cos I can see in my pgadmin. I am puzzled on the return error which I don’t understand. The table is not empty…

The pgadmin and postgres r run in docker in docker-compose. For the n8n, I pulled it out and run in the docker . I use the ip in the postgres container to connect to the n8n postgres

Thanks

If Postgres is available via localhost can you try using localhost in the Host field, in the credentials? I don’t have a lot of experience with Postgres, but using localhost as the Host and the correct credentials helped me connect with my Postgres db.

1 Like

Thank you. i finally get it to work Yahoo!! it is due to the credential and some networking issue. thanks for the inspiration.

1 Like

I am happy that you were able to find a solution!

Have fun :tada:

1 Like