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