Database does not exist!

Screen Link:

import psycopg2
conn = psycopg2.connect('dbname=dq, user=dq')
cur = conn.cursor()
cur.execute("CREATE TABLE ign_restricted (id bigint PRIMARY KEY, title varchar(200), release_date date);")
    INSERT INTO ign_restricted (id, title, release_date) 
    SELECT id, title, release_date FROM ign_reviews;

What I expected to happen: the code to run without errors!

What actually happened:

OperationalErrorTraceback (most recent call last)
<ipython-input-1-cea9aa0f7afe> in <module>()
      1 import psycopg2
----> 3 conn = psycopg2.connect('dbname=dq, user=dq')
      4 cur = conn.cursor()

/dataquest/system/env/python3/lib/python3.4/site-packages/psycopg2/ in connect(dsn, database, user, password, host, port, connection_factory, cursor_factory, async, **kwargs)
    162                 for (k, v) in items])
--> 164     conn = _connect(dsn, connection_factory=connection_factory, async=async)
    165     if cursor_factory is not None:
    166         conn.cursor_factory = cursor_factory

OperationalError: FATAL:  database "dq," does not exist

Help! I think something is wrong.

Just a quick question: what do you see in the error message?
Exactly last line, where it says: “OperationalError: FATAL:” ?

Hint 1: if you still miss it, let me know, I will help :slight_smile:
Hint 2: Official docs are also helpful, when you pay attention to the examples.

Ah, okay
So, that comma, I don’t know where it came from :wink:


Thank you!

1 Like