I'm trying to write a Python script which will anonymise users stored in a production database in bulk. This is using an existing routine which has been used many times before and works fine.
My code looks like this:
with open('users_to_delete.csv', newline='') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',', quotechar='|')
for row in csv_reader:
user_to_delete = row[0]
delete_query = """CALL anonymise_accounts(""" + user_to_delete + ');'
cursor.execute(delete_query, multi=True)
db_connection.commit()
When running it, the following output is returned:
CALL anonymise_accounts(5308561);
CALL anonymise_accounts(2558082);
However, the accounts don't get anonymised.
I'd appreciate any ideas where I may be going wrong here.
CALL anonymise_accounts(5308561);directly in database to see if it really works. maybe this function doesn't delete accounts.