Create data¶
Insert a record into the database:
7cursor.execute("""INSERT INTO books 8 VALUES ('Python basics', 'en', 'Veit Schiele', 'BSD', 9 '2021-10-28')""")
Save data to database:
12conn.commit()
Insert multiple records using the more secure
?method where the number of?should correspond to the number of columns:15new_books = [ 16 ("Jupyter Tutorial", "en", "Veit Schiele", "BSD-3-Clause", "2019-06-27"), 17 ("Jupyter Tutorial", "de", "Veit Schiele", "BSD-3-Clause", "2020-10-26"), 18 ("PyViz Tutorial", "en", "Veit Schiele", "BSD-3-Clause", "2020-04-13"), 19] 20cursor.executemany("INSERT INTO books VALUES (?,?,?,?,?)", new_books) 21conn.commit()