我試圖用psycopg2連接到一個Postgres數據庫:Psycopg2: '模塊' 對象有沒有屬性 '連接'
import psycopg2
try:
conn = psycopg2.connect("dbname='puppetdb' user='puppetdb' host='172.17.0.1' port='5432' password='puppetdb'")
except Exception, e:
print "I am unable to connect to the database"
print e
將返回:
I am unable to connect to the database
'module' object has no attribute 'connect'
我已確認psycopg2與pip install psycopg2
一起安裝,它似乎應該根據documentation工作。
我做錯了嗎?