Загрузка...

Lesson - 57 : Python Advanced - Python Database Access : MySQL Delete Data

************************************************** Python Core PlayList : https://www.youtube.com/watch?v=_laUbUtzMOs&list=PLxWzQv_1I_ACFomYYjF0HMqmu-w2pyqta Python Advanced PlayList : https://www.youtube.com/watch?v=RSKv-gSKrpA&list=PLxWzQv_1I_ACjp_DGDwHlTZlndqi4cu0_ ************************************************** Python Database Access : MySQL Update Data: To update data in a MySQL table in Python, you follow the steps below: Connect to the database by creating a new MySQLConnection object. Create a new MySQLCursor object from the MySQLConnection object and call the execute()method of the MySQLCursor object. To accept the changes, you call the commit() method of the MySQLConnection object after calling the execute() method. Otherwise, no changes will be made to the database. Close the cursor and database connection. Example : db_config = read_db_config() # prepare query and data query = """ UPDATE books SET title = %s WHERE id = %s """ data = (title, book_id) conn = MySQLConnection(**db_config) # update book title cursor = conn.cursor() cursor.execute(query, data) # accept the changes conn.commit() Sample Projects : https://github.com/SadaLearningHub1/Python3-Core-And-Advanced-Examples

Видео Lesson - 57 : Python Advanced - Python Database Access : MySQL Delete Data автора Питон и перевоплощение программирования
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки