37,719
社区成员
发帖
与我相关
我的任务
分享
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import psycopg2
conn = psycopg2.connect(host='127.0.0.1',
port='5432',
database='postgres',
user='postgres',
password='12345',
sslmode='require')
cur = conn.cursor()
cur.execute('SELECT * FROM tablename')
如果不行可能是安装时没有带ssl支持.
在安装Psycopg2的时候,应该用源码安装, 编译程序时候带上 --with-openssl 选项.