我正在使用下面的方法try 将一条记录插入postgresql数据库表,但它不起作用.我没有发现任何错误,但表中没有记录.我需要promise 吗?我使用的是与Bitnami djangostack安装一起安装的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"