• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python操作sqlite的CRUD实例分析

python操作sqlite的CRUD实例分析

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了crud,crud是什么意思,crud操作,增删改查crud,crud应用等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python操作sqlite的CRUD实现方法。分享给大家供大家参考。具体如下:

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]))
</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • python操作sqlite的CRUD实例分析

相关文章

  • Python编程中运用闭包时所需要注意的一些地方
  • 在Python中操作时间之tzset()方法的使用教程
  • 跟老齐学Python之集合(set)
  • 一些Python中的二维数组的操作方法
  • python3简单实现微信爬虫
  • pyqt4教程之实现半透明的天气预报界面示例
  • 详解Python编程中包的概念与管理
  • 利用Python自动监控网站并发送邮件告警的方法
  • python解决方案:WindowsError: [Error 2]
  • python的tkinter布局之简单的聊天窗口实现方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python ORM框架SQLAlchemy学习笔记之关系映射实例
    • 使用Python神器对付12306变态验证码
    • python daemon守护进程实现
    • Python中用于转换字母为小写的lower()方法使用简介
    • python获取android设备的GPS信息脚本分享
    • 详解在Python程序中解析并修改XML内容的方法
    • Python中处理unchecked未捕获异常实例
    • python中反射用法实例
    • Python中几种操作字符串的方法的介绍
    • python类继承与子类实例初始化用法分析

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有