python链接postgresql

Posted kerwin cui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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="dbname", user="username", password="userpwd", host="dbaddress", port="5432")
cur = conn.cursor()  
cur.execute("update table set name=‘‘")  
conn.commit()  
cur.close()  
conn.close()

  


以上是关于python链接postgresql的主要内容,如果未能解决你的问题,请参考以下文章