January 2019
Beginner
318 pages
8h 23m
English
Now, we will insert the data into our table. For that, we will create a insert_data.py script and write the following content in it:
import sqlite3con_obj = sqlite3.connect("test.db")with con_obj: cur_obj = con_obj.cursor() cur_obj.execute("INSERT INTO books VALUES ('Pride and Prejudice', 'Jane Austen')") cur_obj.execute("INSERT INTO books VALUES ('Harry Potter', 'J.K Rowling')") cur_obj.execute("INSERT INTO books VALUES ('The Lord of the Rings', 'J. R. R. Tolkien')") cur_obj.execute("INSERT INTO books VALUES ('Murder on the Orient Express', 'Agatha Christie')") cur_obj.execute("INSERT INTO books VALUES ('A Study in Scarlet', 'Arthur Conan Doyle')") con_obj.commit()print("Data inserted Successfully !!")
Run the script and ...
Read now
Unlock full access