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装饰器的执行过程实例分析

关于Python装饰器的详细介绍

没学过编程可以学Python

Python是计算机语言吗

详谈Python在windows中的文件路径问题

初学者Python能用代码做什么

Python学哪个web框架好?2019 Python web框架排行

详解Python中super()函数的用法及工作原理

Python中元类与枚举类的介绍(代码示例)

Python遍历文件夹下所有文件

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




打赏

取消

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

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

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

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

评论

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