python链接postgresql
#需要安装的库 sudo apt-get install build-dep python-psycopg2 pip install psycopg2 #!/usr/bin/python # -*- coding: UTF-8 -*- import psycopg2 #连接数据库 conn = psycopg2.connect(database="sde_pg_10_3", user="postgres", password="pgsql_93", host="docker703.gdepb.gov.cn", port="2932") cur = conn.cursor() cur.execute("update water_quality_level set level_html=''") conn.commit() #查询使用 #rows = cur.fetchall() #print(rows) #for row in rows: #print "ID = ", row[0] #print "NAME = ", row[1] cur.close() conn.close()