Bug in PostgreSQL docs Python code

Problem description:

Who wrote this? Why didn’t they test the code?

Expected behavior:

import os

import psycopg2.pool

# Create a connection pool with a min_size of 0 and a max_size of 80
# Use the `DATABASE_URL` environment variable we provide to connect to the Database
# It is included in your Replit environment automatically (no need to set it up)
pool = psycopg2.pool.SimpleConnectionPool(0, 80, os.environ['DATABASE_URL'])

Actual behavior:

import psycopg2.pool

# Create a connection pool with a min_size of 0 and a max_size of 80
# Use the `DATABASE_URL` environment variable we provide to connect to the Database
# It is included in your Replit environment automatically (no need to set it up)
pool = psycopg2.pool.SimpleConnectionPool(0, 80, process.env.DATABASE_URL)

Bug appears at this link:
https://docs.replit.com/hosting/databases/postgresql-on-replit#usage-python
https://docs.replit.com/hosting/databases/postgresql-on-replit#final-code-1

Thank you @QwertyQwerty88. I’ll create a task internally to update the documentation here.

6 Likes

Hello,
I was trying to test PostgreSQL and noticed this error on the documentation.

Can you please fix it ? new users may be troubled by such an error in the official documentation.

1 Like

Thanks @fvillemin. I did file a task with the documentation team to fix it. I’ll bubble it up again.

1 Like

This should be fixed now. Thanks again.

1 Like

Well that’s better, but os is never imported, so it would raise an error.

Oh shoot, you’re right, looks like that was missed. We’ll get it included.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.