#!/usr/bin/env python import report, sys import psycopg2.extras parser = report.get_parser(sys.argv[0]) parser.add_argument('--title', '-t', required=False, dest='title', default="Data Dictionary", help='Report Title') args = parser.parse_args() conn = report.get_connection(args) curs = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) def get_dictionary(): q = """ select t1.nspname as schema, count(*) as count from pg_namespace t1 join information_schema.tables t2 on t1.nspname = t2.table_schema left outer join pg_description t3 on t1.oid = t3.objoid where t1.nspname not in ('information_schema', 'pg_catalog') group by schema, description order by schema """ curs.execute(q)
#!/usr/bin/env python import report, sys import psycopg2.extras reload(sys) sys.setdefaultencoding('utf8') parser = report.get_parser(sys.argv[0]) parser.add_argument('--title', '-t', required=False, dest='title', default="Data Dictionary", help='Report Title') args = parser.parse_args() conn = report.get_connection(args) curs = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) def get_dictionary(): q = """ select t1.nspname as schema, t3.description, count(*) as count from pg_namespace t1 join information_schema.tables t2 on t1.nspname = t2.table_schema left outer join pg_description t3 on t1.oid = t3.objoid where t1.nspname not in ('information_schema', 'pg_catalog') group by schema, description order by schema """ curs.execute(q) schemas = curs.fetchall()