0

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
anvd
  • 3,997
  • 19
  • 65
  • 126
  • I'm not familiar with postgres, but from the docs it looks like `get_tables` is a method for a `DB` object, not a `pgobject` connection object. – Tim Nov 12 '13 at 10:34

1 Answers1

0

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()
sherwoor
  • 185
  • 6