python executemany 详解python中executemany和序列如何使用

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python executemany 详解python中executemany和序列如何使用

  2021-03-29 我要评论
想了解详解python中executemany和序列怎样使用的相关内容吗,在本文为您仔细讲解python executemany的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:python,executemany,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和序列的应用,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们