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

Python簡(jiǎn)單操作sqlite3的方法示例

 更新時(shí)間:2017年03月22日 10:43:41   作者:聰明的狐貍  
這篇文章主要介紹了Python簡(jiǎn)單操作sqlite3的方法,結(jié)合實(shí)例形式分析了Python針對(duì)sqlite3數(shù)據(jù)庫(kù)的讀取、創(chuàng)建、增刪改查等基本操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Python簡(jiǎn)單操作sqlite3的方法。分享給大家供大家參考,具體如下:

import sqlite3
def Test1():
  #con =sqlite3.connect("D:\\test.db")
  con =sqlite3.connect(":memory:") #store in memory
  cur =con.cursor()
  try:
    cur.execute('create table score(id integer primary key,name varchar(10),scores integer)')
    cur.execute("insert into score values(0,'Rose',87)")
    cur.execute("insert into score values(1,'Alice',78)")
    cur.execute("insert into score values(2,'Helon',100)")
    cur.execute("insert into score values(3,'Tom',98)")
    cur.execute("insert into score values(4,'jack',198)")
    cur.execute("insert into score values(5,'Tony',198)")
    cur.execute("insert into score values(6,'David',99)")
    cur.execute("update score set scores =? where id=?",(45,3))
    cur.execute("update score set name=? where id=?",("John",0))
    cur.execute("delete from score where id =1")
  except Exception,e:
    print "There are some except",e
  con.commit()
  print "Insert Complete"
  print "-----------------------------------------"
  print "Last row id is ",cur.lastrowid
  cur.execute('select * from score')
  print cur.fetchall()
  print "----------------------------------------"
  cur.execute("select count(*) from score")
  print "Current Rows is :",cur.fetchall()[0]
  cur.close()
  con.close()
if __name__ =='__main__':
  Test1()
  print "hello world"

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總》、《Python編碼操作技巧總結(jié)》、《Python圖片操作技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python Socket編程技巧總結(jié)》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

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

相關(guān)文章

最新評(píng)論

中江县| 隆子县| 邓州市| 茂名市| 华容县| 京山县| 东海县| 卢龙县| 边坝县| 师宗县| 肥西县| 阿坝县| 长治县| 大庆市| 岳阳市| 中江县| 民县| 宕昌县| 简阳市| 肥乡县| 襄垣县| 若羌县| 伊通| 盘山县| 迭部县| 玛多县| 石河子市| 深水埗区| 乐业县| 鹰潭市| 乾安县| 玉树县| 淳安县| 五大连池市| 乐清市| 河西区| 景洪市| 讷河市| 喀什市| 旌德县| 康马县|