I have the following code
conn = MySQLdb.connect(server, user, password, database, autocommit=True, charset='utf8')
for e in list_to_updpate:
nid = e[0]
vid = e[1]
text = e[2]
delta = e[3]
deleted = e[4]
langcode = e[5]
to_update = e[6]
if (to_update == 1):
with conn.cursor() as cursor:
cursor.execute("""update node__body set body_value=%s
where entity_id=%s AND revision_id=%s AND
delta=%s AND deleted=%s AND langcode=%s;""" ,
(MySQLdb.escape_string(text) , int(nid),
int(vid), int(delta), int(deleted), langcode, ))
conn.commit()
conn.close()
Where I have the list of entries I want to update and text is a LONG TEXT which can contain anything from the UTF8 table.
When I run the code I notice 2 things:
- It runs for a while but nothing gets updated.
At some point it crashes with the error:
_mysql_exceptions.OperationalError: (1242, 'Subquery returns more than 1 row')
This I can not get a grip of it and more I am sure that only one row gets updated since as per table definition the primary key is defined as (entity_id, revision_id, delta, deleted, langcode)
Note: This behavior is repeated with pymysql and with MySQL-client on python3.6
Regards, T