代码拉取完成,页面将自动刷新
import sqlite3
# # 打开或者创建数据库文件
# conn = sqlite3.connect("test.db")
# print("成功打开数据库")
#
# #获取游标
# c = conn.cursor()
#
# sql = '''
# create table testinfo
# (id int primary key not null ,
# name varchar(30) not null ,
# director varchar(30) not null ,
# starring varchar(30) not null ,
# nation varchar(30) not null );
# '''
#
# c.execute(sql) #执行sql语句
# conn.commit() #提交数据库操作
# conn.close() #关闭数据库连接
#
# print("成功建表")
#
# 插入数据
conn = sqlite3.connect("test.db")
print("成功打开数据库")
#获取游标
c = conn.cursor()
# sql = '''
# insert into testinfo(id,name,director,starring,nation)
# values (1,"a1","a2","a3","中国"),
# (2,"b1","b2","b3","中国");
#
# '''
sql = '''
insert into testinfo(id,name,director,starring,nation)
values (3,"c1","c2","c3","中国"),
(4,"d1","d2","d3","中国"),
(5,"e1","e2","e3","美国"),
(6,"f1","f2","f3","美国"),
(7,"g1","g2","g3","美国"),
(8,"h1","h2","h3","英国"),
(9,"i1","i2","i3","英国"),
(10,"j1","j2","j3","英国");
'''
c.execute(sql) #执行sql语句
conn.commit() #提交数据库操作
conn.close() #关闭数据库连接
print("插入完毕")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。