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 ()
It is most likely a lock in the database, with thread/processes trying to update the same record.
import psycopg2
conn = psycopg2.connect(
database="dbasename",user="username",
password='your_password',host='web_address',
port='your_port')
cursor = conn.cursor()
cursor.execute(
"UPDATE table_name SET update_column_name=(%s)"
" WHERE ref_column_id_value = (%s)",
("column_name","value_you_want_to_update",));
conn.commit()
cursor.close()
You did not format your execute statement correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With