Postgres Implementation not working

Hello, I’m trying to use the built-in Neon Postgres table in python however it’s throwing weird errors.
I’m using this tutorial: https://docs.replit.com/hosting/databases/postgresql-on-replit#usage-python

  1. When I use “process.env.DATABASE_URL” it doesn’t work saying that there is no module called process. When I import process, it says there’s no environment variable DATABASE_URL. To get around this I just pasted the url that the postgres area gives me and it seems to connect.

  2. When I try to add a new table it gives me the error: “psycopg2.errors.DuplicateTable: relation “brokerdata” already exists”. Even though I’ve just created the database and there are no tables in it.

  3. When I try to write, it gives duplicate error for some rows but no error for others. However no rows actually show up in the database.

help!!!

Hi @HadiLaasi1, welcome to the community!

Weird, that’s a Node.js thing, why would it ask you to use that? Maybe try import os and os.environ["DATABASE_URL"]. Then use the Secrets tab to create a Secret called “DATABASE_URL” and set the value to:

I don’t know about the other errors, never used Postgres but maybe someone who has can help you out :woman_shrugging:

2 Likes