Python操作sqllite3

import sqlite3
#操作Sqlite3
con=sqlite3.connect(r"F:\\baidu download\\test.db")
cour=con.cursor()

# cour.execute("create table mytab(id integer primary key autoincrement not null,name text,passwd text)")
# cour.execute("insert into mytab(name,passwd) values(?,?)",("bobo","4565892",))
# cour.executemany("insert into mytab(name,passwd) values(?,?)",[("dao","123"),("liming","654"),("fsdfsdf","65656")],)
# print('显示记录')
# cour.execute("select * from mytab")
# for k,v,d in cour:
#     print(k,v,d)
# print("更新一条记录")
# cour.execute("update mytab set name=? where id=?",("aaa",1))
# print("显示所有记录")
# cour.execute("select * from mytab")
# for item in cour.fetchall():
#     print(item)
#
# cour.execute("delete from mytab where id=?",(1,))
# print("显示所有记录")
# cour.execute("select * from mytab")
# for q,w,e in cour:
#     print(q,w,e)
cour.close()
con.close()

你可能感兴趣的:(Python高级编程)