سؤال

I have a connection with :

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
        )

When I run the query to insert self.cursor.execute("INSERT INTO Divers (email, hashpass) VALUES (%s, %s);",[email, password]) it returns successfully.

However, when I check my data the registration isn't there. When I run this query through the CLI it inserts but the incremented id is increased as if values had been inserted. Pleas help.

هل كانت مفيدة؟

المحلول

The documentation shows a commit() method commit. So you probably want to try using it like this:

self.conn.commit()
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top