Cannot connect to Postgres sample database

Screen Link:
I cannot connect to the Postgres database for this exercise
I tried this

import psycopg2
conn = psycopg2.connect("dbname = dq, user = dq")

I got “We could not find any connection to the database.”
OperationalError: FATAL: database "dq," does not exist

Hey, Sarah.

If you take a look at the Learn section, or look at the documentation (of which a screenshot you can find below), you’ll see that if you pass the connection details as a string to the method, the parameter=argument data should be separated by spaces, not commas.

You get the error OperationalError: FATAL: database "dq," does not exist, because after the command, the parser finds a space and assumes that the database you’re trying to connect to is called dq, (not dq), which results in an error because dq, doesn’t exist.

An alternative, as per the documentation, is to pass several parameters to the method, like so:

import psycopg2
conn = psycopg2.connect(dbname = "dq", user = "dq")