热线电话:13121318867

登录
首页精彩阅读详解python中executemany和序列的使用方法
详解python中executemany和序列的使用方法
2017-09-21
收藏

详解python中executemany和序列的使用方法

这篇文章主要介绍了详解python中executemany和序列的使用方法,

一 代码    
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")

 二 运行结果    
y ========
('Jim', 'Green')
('Hu', 'jie')
I just deleted 2 rows

以上就是python中executemany和序列的应用

数据分析咨询请扫描二维码

若不方便扫码,搜微信号:CDAshujufenxi

最新资讯
更多
客服在线
立即咨询