我正在使用以下嘗試插入一個記錄到postgresql數據庫表中,但它不工作。我沒有收到任何錯誤,但表中沒有記錄。我需要提交還是什麼?我使用的是與Bitnami djangostack安裝一起安裝的postgresql數據庫。python psycopg2沒有插入postgresql表
import psycopg2
try:
conn = psycopg2.connect("dbname='djangostack' user='bitnami' host='localhost' password='password'")
except:
print "Cannot connect to db"
cur = conn.cursor()
try:
cur.execute("""insert into cnet values ('r', 's', 'e', 'c', 'w', 's', 'i', 'd', 't')""")
except:
print "Cannot insert"
警告:'除了:'子句捕獲沒有特定的異常對調試代碼沒有任何幫助。 – bernie