1import pandas as pd
2import pandas.io.sql as sqlio
3import psycopg2
4
5conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd))
6sql = "select count(*) from table;"
7dat = sqlio.read_sql_query(sql, conn)
8conn = None