Create data from csv#

  1. Import the sqlite and csv modules

    1import csv
    2import sqlite3
  2. Point to the Library Database

    4conn = sqlite3.connect("library.db")
    5cursor = conn.cursor()
  3. Read the csv file and insert the records into the database:

     8with open("books.csv", encoding="utf-8") as f:
     9    reader = csv.reader(f, delimiter=",")
    10    cursor.executemany("INSERT INTO books VALUES (?,?,?,?,?)", reader)
  4. Save data to database: