Hi,
I'm teaching a basic database programming course and want my students to use python3 to interact with a SQLite database.
I attach the DB as a support file (similar to how I would create an SQL question). However, if I try to run anything other than SELECT queries I get an error stating that I am trying to write to a read-only database.
For example (this code works):
import sqlite3
conn = sqlite3.connect('SimpleBooks.db')
cursor = conn.cursor()
for row in cursor.execute('''SELECT * FROM Authors;'''):
print(row)
cursor.close()
This does not work
import sqlite3
conn = sqlite3.connect('SimpleBooks.db')
cursor = conn.cursor()
cursor.execute('''INSERT INTO Authors (Name, Surname) VALUES ('Stephen','King') ;''')
cursor.close()
Any advice on how I can get this database to behave the same way one in an SQL question type would behave?