Search code examples
pythonpsycopg2

psycopg2 (insert, update) writing problem


I can send select queries with any problem but when I send update and insert queries it start to wait the thread and don't respond anymore. I couldn't be sure but it seems like a loop.

I know we must use "commit()" for applying changes but it doesn't work.

Here is my code:

import psycopg2
conn = psycopg2.connect("dbname='test' user='postgres' host='localhost' password='xx");
cursor = conn.cursor()
cursor.execute("UPDATE recording SET rank = 10 WHERE id = 10;")
conn.commit()
cursor.close ()

Solution

  • The problem is psycopg2 doesn't have support for threading.