在heroku上插入postgres执行但不会停留

时间:2014-02-05 20:38:42

标签: python postgresql heroku psycopg2

我与:

有联系
url = urlparse.urlparse(os.environ["DATABASE_URL"])
self.conn = psycopg2.connect(
            database=url.path[1:],
            user=url.username,
            password=url.password,
            host=url.hostname,
            port=url.port
        )

当我运行查询以插入self.cursor.execute("INSERT INTO Divers (email, hashpass) VALUES (%s, %s);",[email, password])时,它会成功返回。

然而,当我检查我的数据时,注册不存在。当我通过CLI运行此查询时,它会插入,但增加的id会增加,就像插入了值一样。请帮助。

1 个答案:

答案 0 :(得分:1)

文档显示了commit()方法commit。所以你可能想尝试使用它:

self.conn.commit()