详解python中executemany和序列的使用方法
一 代码
import sqlite3
persons=[
("Jim","Green"),
("Hu","jie")
]conn=sqlite3.connect(":memory:")
conn.execute("CREATE TABLE person(firstname,lastname)")
conn.executemany("INSERT INTO person(firstname,lastname) VALUES(?,?)",persons)
for row in conn.execute("SELECT firstname,lastname FROM person"):
print(row)
print("I just deleted",conn.execute("DELETE FROM person").rowcount,"rows")
二 运行结果
y ========
('Jim', 'Green')
('Hu', 'jie')
I just deleted 2 rows
以上就是python中executemany和序列的应用,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
您可能感兴趣的文章:用PyInstaller把Python代码打包成单个独立的exe可执行文件使用PyInstaller将python转成可执行文件exe笔记通过Py2exe将自己的python程序打包成.exe/.app的方法python学习笔记–将python源文件打包成exe文件(pyinstaller)使用python编写简单的小程序编译成exe跑在win10上解析Python中的eval()、exec()及其相关函数python的exec、eval使用分析python学习教程之使用py2exe打包Python之py2exe打包工具详解详解Python3.6的py文件打包生成exe