欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python操作sqlite的CRUD實例分析

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

本文實例講述了python操作sqlite的CRUD實現(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]))

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

相關(guān)文章

  • Python的logging.config模塊操作步驟

    Python的logging.config模塊操作步驟

    這篇文章主要介紹了Python的logging.config模塊操作步驟,本文通過示例代碼給大家介紹的非常詳細對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-08-08
  • python selenium 獲取接口數(shù)據(jù)的實現(xiàn)

    python selenium 獲取接口數(shù)據(jù)的實現(xiàn)

    這篇文章主要介紹了python selenium 獲取接口數(shù)據(jù)的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Python實現(xiàn)同時調(diào)用多個GPT的API

    Python實現(xiàn)同時調(diào)用多個GPT的API

    這篇文章主要為大家詳細介紹了Python如何實現(xiàn)同時調(diào)用多個GPT的API,文中的示例代碼簡潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-09-09
  • python使用seaborn繪圖直方圖displot,密度圖,散點圖

    python使用seaborn繪圖直方圖displot,密度圖,散點圖

    這篇文章主要介紹了python使用seaborn繪圖直方圖displot,密度圖,散點圖,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-07-07
  • python 實現(xiàn)二維字典的鍵值合并等函數(shù)

    python 實現(xiàn)二維字典的鍵值合并等函數(shù)

    今天小編就為大家分享一篇python 實現(xiàn)二維字典的鍵值合并等函數(shù),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • python實現(xiàn)按日期歸檔文件

    python實現(xiàn)按日期歸檔文件

    這篇文章主要介紹了python實現(xiàn)如何按日期歸檔文件,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2021-01-01
  • PyTorch搭建LSTM實現(xiàn)多變量多步長時序負荷預(yù)測

    PyTorch搭建LSTM實現(xiàn)多變量多步長時序負荷預(yù)測

    這篇文章主要為大家介紹了PyTorch搭建LSTM實現(xiàn)多變量多步長時序負荷預(yù)測,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-05-05
  • Numpy掩碼式數(shù)組詳解

    Numpy掩碼式數(shù)組詳解

    下面小編就為大家分享一篇Numpy掩碼式數(shù)組詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-04-04
  • python使用pandas實現(xiàn)篩選功能方式

    python使用pandas實現(xiàn)篩選功能方式

    在數(shù)據(jù)分析的過程中通常要對數(shù)據(jù)進行清洗與處理,而其中比較重要和常見的操作就有對數(shù)據(jù)進行篩選與查詢,下面這篇文章主要給大家介紹了關(guān)于python使用pandas實現(xiàn)篩選功能方式的相關(guān)資料,需要的朋友可以參考下
    2022-06-06
  • python動態(tài)視頻下載器的實現(xiàn)方法

    python動態(tài)視頻下載器的實現(xiàn)方法

    這里向大家分享一下python爬蟲的一些應(yīng)用,主要是用爬蟲配合簡單的GUI界面實現(xiàn)視頻,音樂和小說的下載器。今天就先介紹如何實現(xiàn)一個動態(tài)視頻下載器,需要的朋友可以參考下
    2019-09-09

最新評論