import psycopg2, sys sys.stdout.reconfigure(encoding='utf-8') conn = psycopg2.connect(host='192.168.110.252', port=15432, dbname='postgresql', user='postgresql', password='Jchl1528', options='-c search_path=healthlink_his') cur = conn.cursor() # Execute knowledge base SQL with open(r'D:\his\healthlink-his-server\insert_knowledge_base.sql', 'r', encoding='utf-8') as f: sql = f.read() cur.execute(sql) conn.commit() cur.execute('SELECT COUNT(*) FROM clinical_knowledge_base') print('clinical_knowledge_base rows:', cur.fetchone()[0]) # Execute preop discussion SQL with open(r'D:\his\healthlink-his-server\insert_preop_discussion.sql', 'r', encoding='utf-8') as f: sql = f.read() cur.execute(sql) conn.commit() cur.execute('SELECT COUNT(*) FROM sys_preop_discussion') print('sys_preop_discussion rows:', cur.fetchone()[0]) cur.execute('SELECT COUNT(*) FROM sys_preop_participant') print('sys_preop_participant rows:', cur.fetchone()[0]) cur.close() conn.close() print('Done!')