Update data¶
Change a license
4def update_license(old_name, new_name): 5 conn = sqlite3.connect("library.db") 6 cursor = conn.cursor() 7 sql = f""" 8 UPDATE books 9 SET license = '{new_name}' 10 WHERE license = '{old_name}' 11 """ 12 cursor.execute(sql) 13 conn.commit()
Calling the method:
16update_license(old_name="BSD", new_name="BSD-3-Clause")