I can connect to my database, but psycopg2 fails to find any of my tables. The following will error trying to get my users:
import psycopg2
try:
conn = psycopg2.connect("dbname='pdb' user='postgres' host='localhost' password='password'")
except:
print 'failed to connect'
cur = conn.cursor()
cur.execute(""" SELECT * from Users """)
rows = cur.fetchall()
for row in rows:
print row[0]
#Error:
psycopg2.ProgrammingError: relation "users" does not exist
LINE 1: SELECT * from Users
# This also fails
cur.execute("""SELECT * from pdb.Users """)
If I do:
cur.execute(""" SELECT * from pg_database """)
# Outputs
template1
template0
postgres
pdb
In my admin panel, pdb shows a bunch of tables, one of them being Users, so I'm not sure why psycopg2 can't find it.
Here's a printout from psql for pdb:
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+----------
public | Companies | table | postgres
public | Users | table | postgres
(2 rows)