9 Star 1 Fork 2

lonelyway/MoviesAnalysingSystem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
database.py 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
lonelyinnovator 提交于 2022-06-22 11:20 . 整合数据分析和可视化
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("插入完毕")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lonelyinnovator/movies-analysing-system.git
git@gitee.com:lonelyinnovator/movies-analysing-system.git
lonelyinnovator
movies-analysing-system
MoviesAnalysingSystem
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385