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

2019/7/13 22:52:18

本文主要是介绍详解python中executemany和序列的使用方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

详解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和序列的应用,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!



这篇关于详解python中executemany和序列的使用方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程