Screen Link:
https://app.dataquest.io/m/258/exploring-postgres-internals/4/describing-the-tables
My Code:
tables = cur.fetchall()
col_descriptions = {}
for row in tables:
cur.execute ("SELECT * FROM %s LIMIT 0;", (AsIs(row),))
col_descriptions[row] = cur.description
conn.close()
What I expected to happen:
To work without errors
What actually happened:
I get an error
Replace this line with the output/error
SyntaxError Traceback (most recent call last)
in
18 col_descriptions = {}
19 for row in tables:
—> 20 cur.execute (“SELECT * FROM %s LIMIT 0;”, (AsIs(row),))
21 col_descriptions[row] = cur.description
22
SyntaxError: syntax error at or near “‘crimes.boston_crimes’”
LINE 1: SELECT * FROM (‘crimes.boston_crimes’,) LIMIT 0;
I am connecting to my PostgreSQL instance at AWS. The format of the contents returned by cur.fetchall() is different than the format returned from the Dataquest console.
Here’s the contents returned from my cur.fetchall()
[(‘crimes.boston_crimes’,)]
And here’s the contents of the Dataquest cur.fetchall()
[‘homeless_by_coc’, ‘state_household_incomes’, ‘state_info’]
How did you remove the parenthesis?