import sqlite3 conn=sqlite3,connect('test.db') c=conn.cursor() c.execute("insert into book values(1,1,'kitchen')") c.execute("insert into book values(?,?,?)",[(2,2,'computer')]) books=[(1,1,'cookRecipe',3,12,1), (2,3,'python inero',17.5,2), (3,2,'OS intero',13.6,2), ] c.executemany('insert into book values(?,?,?,?,?)',books) conn.commit() c.execute('select name from book order by id ') print(c.fetchone()) print(c.fetchall()) for row in c.execute('select * from book order by id ') print(row) conn.close()
|