我正在使用下面的方法来尝试向一个postgresql数据库表插入一条记录,但它没有工作。我没有得到任何错误,但表中没有任何记录。我是否需要提交或什么?我使用的是与Bitnami djangostack安装一起安装的postgresql数据库。
import psycopg2
conn = psycopg2.connect("dbname='djangostack' user='bitnami' host='localhost' password='password'")
except:
print "Cannot connect to db"
cur = conn.cursor()
cur.execute("""insert into cnet values ('r', 's', 'e', 'c', 'w', 's', 'i', 'd', 't')""")
except:
print "Cannot insert"