python操作sqlite的CRUD實(shí)例分析
本文實(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ì)有所幫助。
- Windows平臺(tái)Python連接sqlite3數(shù)據(jù)庫(kù)的方法分析
- Python sqlite3事務(wù)處理方法實(shí)例分析
- Python簡(jiǎn)單操作sqlite3的方法示例
- SQLite3中文編碼 Python的實(shí)現(xiàn)
- 詳解Python 數(shù)據(jù)庫(kù) (sqlite3)應(yīng)用
- Python Sqlite3以字典形式返回查詢結(jié)果的實(shí)現(xiàn)方法
- Python標(biāo)準(zhǔn)庫(kù)之sqlite3使用實(shí)例
- Python SQLite3數(shù)據(jù)庫(kù)操作類分享
- Python操作sqlite3快速、安全插入數(shù)據(jù)(防注入)的實(shí)例
- python操作數(shù)據(jù)庫(kù)之sqlite3打開(kāi)數(shù)據(jù)庫(kù)、刪除、修改示例
- Python操作SQLite簡(jiǎn)明教程
- Python開(kāi)發(fā)SQLite3數(shù)據(jù)庫(kù)相關(guān)操作詳解【連接,查詢,插入,更新,刪除,關(guān)閉等】
相關(guān)文章
python selenium 獲取接口數(shù)據(jù)的實(shí)現(xiàn)
這篇文章主要介紹了python selenium 獲取接口數(shù)據(jù)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12Python實(shí)現(xiàn)同時(shí)調(diào)用多個(gè)GPT的API
這篇文章主要為大家詳細(xì)介紹了Python如何實(shí)現(xiàn)同時(shí)調(diào)用多個(gè)GPT的API,文中的示例代碼簡(jiǎn)潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-09-09python使用seaborn繪圖直方圖displot,密度圖,散點(diǎn)圖
這篇文章主要介紹了python使用seaborn繪圖直方圖displot,密度圖,散點(diǎn)圖,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-07-07python 實(shí)現(xiàn)二維字典的鍵值合并等函數(shù)
今天小編就為大家分享一篇python 實(shí)現(xiàn)二維字典的鍵值合并等函數(shù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-12-12PyTorch搭建LSTM實(shí)現(xiàn)多變量多步長(zhǎng)時(shí)序負(fù)荷預(yù)測(cè)
這篇文章主要為大家介紹了PyTorch搭建LSTM實(shí)現(xiàn)多變量多步長(zhǎng)時(shí)序負(fù)荷預(yù)測(cè),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05python使用pandas實(shí)現(xiàn)篩選功能方式
在數(shù)據(jù)分析的過(guò)程中通常要對(duì)數(shù)據(jù)進(jìn)行清洗與處理,而其中比較重要和常見(jiàn)的操作就有對(duì)數(shù)據(jù)進(jìn)行篩選與查詢,下面這篇文章主要給大家介紹了關(guān)于python使用pandas實(shí)現(xiàn)篩選功能方式的相關(guān)資料,需要的朋友可以參考下2022-06-06python動(dòng)態(tài)視頻下載器的實(shí)現(xiàn)方法
這里向大家分享一下python爬蟲(chóng)的一些應(yīng)用,主要是用爬蟲(chóng)配合簡(jiǎn)單的GUI界面實(shí)現(xiàn)視頻,音樂(lè)和小說(shuō)的下載器。今天就先介紹如何實(shí)現(xiàn)一個(gè)動(dòng)態(tài)視頻下載器,需要的朋友可以參考下2019-09-09