本文摘自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》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python中关于executemany以及序列的实例详解