Executing An Update Delete Query

[Solved] Executing An Update Delete Query | Php - Code Explorer | yomemimo.com
Question : Executing an update/delete query

Answered by : you

import mysql.connector
# Establish the connection
conn = mysql.connector.connect( host="your_host", user="your_username", password="your_password", database="your_database"
)
# Create a cursor to query the database
cursor = conn.cursor()
# Execute an update query
update_query = "UPDATE your_table SET column1 = 'new_value' WHERE condition;"
cursor.execute(update_query)
# Execute a delete query
delete_query = "DELETE FROM your_table WHERE condition;"
cursor.execute(delete_query)
# Commit the changes to the database
conn.commit()
# Close the cursor and the connection
cursor.close()
conn.close()

Source : | Last Update : Tue, 19 Sep 23

Question : Executing an update/delete query

Answered by : attractive-ape-8l49xfwx0cai

/* I received this exception when trying to run a bulk UPDATE query in a non-JTA
(i.e. resource-local) entity manager in Java SE.
I had simply forgotten to wrap my JPQL code in*/
em.getTransaction().begin();
//and
em.getTransaction().commit();

Source : | Last Update : Mon, 22 Mar 21

Answers related to executing an update delete query

Code Explorer Popular Question For Php