【python 连接 Greenplum】python 连接Greenplum数据库

Python和PostgrelSQL进行交互,需要安装三方库,PostgrelSQL跟mysql 的用法类似

pip install psycopg2

例子:

import psycopg2  
  
import psycopg2.extras  
  
conn = psycopg2.connect(host='localhost', port=6432, user='postgres', password='root', database='mytest')  
  
  
cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)   
  
cursor.execute('SELECT * FROM article WHERE id = 1;')  
  
result = cursor.fetchone()  
  
print(result)
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页