import psycopg2 import sys sys.stdout.reconfigure(encoding="utf-8") conn = psycopg2.connect( host="192.168.110.252", port=15432, database="postgresql", user="postgresql", password="Jchl1528", ) cursor = conn.cursor() cursor.execute("SET search_path TO hisdev, public") print("doc_request_form 表字段:") cursor.execute(""" SELECT column_name FROM information_schema.columns WHERE table_schema = 'hisdev' AND table_name = 'doc_request_form' ORDER BY ordinal_position """) for row in cursor.fetchall(): print(f" {row[0]}") print("\nwor_service_request 表字段:") cursor.execute(""" SELECT column_name FROM information_schema.columns WHERE table_schema = 'hisdev' AND table_name = 'wor_service_request' ORDER BY ordinal_position """) for row in cursor.fetchall(): print(f" {row[0]}") cursor.close() conn.close()