python中关于executemany以及序列的实例详解


本文摘自php中文网,作者黄舟,侵删。

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

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

一 代码


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以及序列的实例详解的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python并发之poolexecutor的介绍(附示例)

Python计算平均值

Python中阶乘怎么表示

利用Python实现在同一网络中的本地文件共享方法

Python如何使用unittest测试接口_Python

Python如何创建空列表

Python是解释型语言么

一起深入 Python 类的内部

Python之获取与简单处理金融数据

Python需要学linux吗

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...