`import sqlite3
def create_rdb():
conn=sqlite3.connect("roots.db")
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS roots_store (id INTEGER
PRIMARY KEY,make TEXT,machine TEXT,model TEXT,s_n TEXT,end_user
TEXT,status TEXT)")
conn.commit()
conn.close()
def insert(make,machine,model,s_n,end_user,status):
conn=sqlite3.connect("roots.db")
cur=conn.cursor()
cur.execute("INSERT INTO roots_store VALUES (NULL,?,?,?,?,?,?)",
(make,machine,model,s_n,end_user,status))
conn.commit()
conn.close()
insert('Atlas Copco','Air Compressor','GA200','AP34582','Dangote
Refinery','Sold')
def view():
conn = sqlite3.connect("roots.db")
cur = conn.cursor()
cur.execute('SELECT * FROM roots_store')
rows=cur.fetchall()
conn.close()
return rows
connect()
print(view())`
它假设使用insert函数将详细信息存储在数据库中,并使用printview函数查看它,相反,它给了我
`OperationalError Traceback (most recent call last)
<ipython-input-2-3e5cdcdeeab3> in <module>
15 conn.close()
16
---> 17 insert('Atlas Copco','Air Compressor','GA200','AP34582','Dangote
Refinery','Sold')
18
19 def view():
<ipython-input-2-3e5cdcdeeab3> in insert(make, machine, model, s_n,
end_user, status)
11 conn = sqlite3.connect("roots.db")
12 cur = conn.cursor()
---> 13 cur.execute("INSERT INTO roots_store VALUES
(NULL,?,?,?,?,?,?)",
(make,machine,model,s_n,end_user,status))
14 conn.commit()
15 conn.close()`