sudo apt-get install build-dep python-psycopg2pip install psycopg2#!/usr/bin/python# -*- coding: UTF-8 -*-import psycopg2#连接数据库conn = psycopg2.connect(database="dbname", user="username", password="userpwd", host="dbaddress", port="5432")cur = conn.cursor() cur.execute("update table set name=‘‘") conn.commit() cur.close() conn.close()