1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| self.conn = sqlite3.connect(db)
self.cur = self.conn.cursor()
self.cur.execute("CREATE TABLE IF NOT EXISTS book (id INTEGER PRIMARY KEY, title TEXT, "
"author TEXT, year INTEGER, isbn INTEGER)")
self.conn.commit()
def insert(self,title, author, year, isbn):
#the NULL parameter is for the auto-incremented id
self.cur.execute("INSERT INTO book VALUES(NULL,?,?,?,?)", (title,author,year,isbn))
self.conn.commit()
def delete(self,id):
self.cur.execute("DELETE FROM book WHERE id = ?", (id,))
self.conn.commit()
#conn.close() |
Partager