Problem with psycopg2 (insert, update)

I can send requests with any problem, but when I send updates and insert requests, it starts to wait for the stream and no longer responds. I could not be sure, but it looks like a loop.

I know that we must use "commit ()" to apply the changes, but that will not 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 () 
+7
source share
3 answers

The problem is that psycopg2 does not support streaming processing.

-4
source
 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 the execution statement.

+14
source

Most likely, this is a lock in the database, while the thread / processes are trying to update the same record.

+4
source

All Articles