Psycopg2: cursor.execute is not working properly
<p>So, I have the following code that inserts the data of an old database to a new one:</p>

<pre><code>...    
cur_old.execute("""SELECT DISTINCT module FROM all_students_users_log_course266""")
module_rows = cur_old.fetchall()

for row in module_rows:
    cur_new.execute("""INSERT INTO modules(label) SELECT %s WHERE NOT EXISTS (SELECT 1 FROM modules WHERE label=%s)""", (row[0], row[0]))
...
</code></pre>

<p>The last line executes a query where labels are inserted into the new database table. I tested this query on <code>pgAdmin</code> and it works as I want.</p>

<p>However, when execute the script, nothing is inserted on the <code>modules</code> table. (Actually the sequences are updated, but none data is stored on the table). </p>

<p>Do I need to do anything else after I call the execute method from the cursor?</p>

<p>(Ps. The script is running till the end without any errors)</p>