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