0

The postgresql generated by heroku

When I run the following code I am getting the following result: ['seriesIMDB', 'itd']

import psycopg2

postgresqlStr = "postgresql://...."
conn = psycopg2.connect(postgresqlStr)
cursor = conn.cursor()
cursor.execute("""SELECT relname FROM pg_class WHERE relkind='r'
                  AND relname !~ '^(pg_|sql_)';""")
tables = [i[0] for i in cursor.fetchall()]
print(tables)

Then I run the following code:

import psycopg2

postgresqlStr = "postgresql://...."
conn = psycopg2.connect(postgresqlStr)
cur = conn.cursor()
cur.execute("SELECT * FROM seriesIMDB")
query_results = cur.fetchall()
print(query_results)
cur.close()
conn.close()

I am getting the following errors:

Traceback (most recent call last):
  File "...\a.py", line 6, in <module>
    cur.execute("SELECT * FROM seriesIMDB")
psycopg2.errors.UndefinedTable: relation "seriesimdb" does not exist
LINE 1: SELECT * FROM seriesIMDB

How could I print the table elements?

lajos
  • 1

0 Answers0