当前位置:Gxlcms > 数据库问题 > python 连接PostgrepSQL

python 连接PostgrepSQL

时间:2021-07-01 10:21:17 帮助过:3人阅读

1.python 连接PostgrepSQL的接口:psyCopg

1 conn = psycopg2.connect(database="platoon", user="postgres", password="postgres", host="192.168.10.80", port="5432")
2 cur = conn.cursor()

(1)接口连接的参数:数据库名字,用户名,密码,主机,端口

(2)生成一个游标(暂且这样叫,我还不大清楚)

(3)cur.execute():执行SQL语句

(4)cur.fetchall()

(5) conn.commit()

(6)conn.close()


更好的参考链接: http://www.yiibai.com/html/postgresql/2013/080998.html

 

python 连接PostgrepSQL

标签:

人气教程排行