解析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掌握能力

django中怎么更改默认数据库为mysql(详细过程)

实例讲解Python基于回溯法子集树模板实现图的遍历功能

Python爬取饿了么

两分钟了解Python中的input函数

Python 2.7 pandas 中的read_excel详解

Python能开发单片机吗

Python中time模块与datetime模块的详解

Python教你高效办公,自制屏幕翻译工具

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




打赏

取消

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

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

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

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

评论

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