最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python操作sqlite的CRUD實(shí)例分析

 更新時(shí)間:2015年05月08日 10:18:23   作者:work24  
這篇文章主要介紹了python操作sqlite的CRUD實(shí)現(xiàn)方法,涉及Python操作SQLite數(shù)據(jù)庫(kù)CURD相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了python操作sqlite的CRUD實(shí)現(xiàn)方法。分享給大家供大家參考。具體如下:

import sqlite3 as db
conn = db.connect('mytest.db')
cursor = conn.cursor()
cursor.execute("drop table if exists datecounts")
cursor.execute("create table datecounts(date text, count int)")
cursor.execute('insert into datecounts values("12/1/2011",35)')
cursor.execute('insert into datecounts values("12/2/2011",42)')
cursor.execute('insert into datecounts values("12/3/2011",38)')
cursor.execute('insert into datecounts values("12/4/2011",41)')
cursor.execute('insert into datecounts values("12/5/2011",40)')
cursor.execute('insert into datecounts values("12/6/2011",28)')
cursor.execute('insert into datecounts values("12/7/2011",45)')
conn.row_factory = db.Row
cursor.execute("select * from datecounts")
rows = cursor.fetchall()
for row in rows:
  print("%s %s" % (row[0], row[1]))
cursor.execute("select avg(count) from datecounts")
row = cursor.fetchone()
print("The average count for the week was %s" % row[0])
cursor.execute("delete from datecounts where count = 40")
cursor.execute("select * from datecounts")
rows = cursor.fetchall()
for row in rows:
  print("%s %s" % (row[0], row[1]))

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

麻阳| 西宁市| 绥芬河市| 多伦县| 南木林县| 兴业县| 醴陵市| 凤阳县| 台州市| 宜兰县| 托里县| 蕉岭县| 邯郸市| 呼图壁县| 抚顺市| 庆城县| 石狮市| 安塞县| 义马市| 且末县| 临沂市| 宜君县| 巴林左旗| 平南县| 赞皇县| 望奎县| 庄浪县| 克拉玛依市| 怀化市| 会理县| 达孜县| 庄河市| 舒城县| 水富县| 新平| 五原县| 永康市| 崇礼县| 琼中| 武安市| 临潭县|