List all tables in a postgresql database from python
"""
List all tables in a postgresql database from python
"""
import psycopg2 as pg
import pandas.io.sql as sqlio
pd.set_option('display.float_format', lambda x: '%.4f' %x)
def do(cmd, conn):
dat = sqlio.read_sql_query(cmd, conn)
return dat
dname = ""
pguser = ""
passw = ""
conn = pg.connect("dbname={} user={} password={}".format(dname, pguser, passw))
cmd = """SELECT table_name FROM information_schema.tables
WHERE table_schema = 'public'"""
do(cmd, conn)