脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - 详解python中executemany和序列的使用方法

详解python中executemany和序列的使用方法

2020-12-01 00:45cakin24 Python

这篇文章主要介绍了详解python中executemany和序列的使用方法的相关资料,需要的朋友可以参考下

详解pythonexecutemany序列的使用方法

一 代码

?
1
2
3
4
5
6
7
8
9
10
11
12
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")

 二 运行结果

?
1
2
3
4
y ========
('Jim', 'Green')
('Hu', 'jie')
I just deleted 2 rows

以上就是python中executemany和序列的应用,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

原文链接:http://cakin24.iteye.com/blog/2386459

延伸 · 阅读

精彩推荐