AttributeError: get_tables

199 Views Asked by At

What is the problem of this code? Should show a list of tables

import pg

con = pg.connect(dbname='xxx', host='xxxx', user='xxx')
pgqueryset = con.get_tables()

Traceback (most recent call last):
  File "demo.py", line 42, in <module>
    pgqueryset = con.get_tables()()
AttributeError: get_tables

Docs

Parameters:
None
Returns:
list:   all tables in connected database
1

There are 1 best solutions below

0
On BEST ANSWER

get_tables is on the DB class, which is initialised with the same arguments as connect():

Try:

db = pg.DB(dbname='xxx', host='xxxx', user='xxx')
pgqueryset = db.get_tables()