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

Python简单操作sqlite3的方法示例

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

通过本文主要向大家介绍了python sqlite3,python3 sqlite3,python连接sqlite3,sqlite3使用方法,sqlite3安装方法等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了Python简单操作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"

</div>

更多关于Python相关内容感兴趣的读者可查看本站专题:《Python常见数据库操作技巧汇总》、《Python编码操作技巧总结》、《Python图片操作技巧总结》、《Python数据结构与算法教程》、《Python Socket编程技巧总结》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》

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

</div>

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

  • 使用Python对SQLite数据库操作
  • Python简单操作sqlite3的方法示例
  • SQLite3中文编码 Python的实现
  • SQLite3中文编码 Python的实现
  • 详解Python 数据库 (sqlite3)应用
  • Python解析excel文件存入sqlite数据库的方法
  • python从sqlite读取并显示数据的方法
  • python实现在sqlite动态创建表的方法
  • python查询sqlite数据表的方法
  • 在Python中使用SQLite的简单教程

相关文章

  • Python中使用copy模块实现列表(list)拷贝
  • python杀死一个线程的方法
  • 通过实例解析python描述符原理作用
  • Python实现基于HTTP文件传输实例
  • Python中str is not callable问题详解及解决办法
  • Python的面向对象思想分析
  • pygame学习笔记(2):画点的三种方法和动画实例
  • 动态创建类实例代码
  • Python中的生成器和yield详细介绍
  • python 实现删除文件或文件夹实例详解

文章分类

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

最近更新的内容

    • python笔记(1) 关于我们应不应该继续学习python
    • Python列表计数及插入实例
    • Python中最常用的操作列表的几种方法归纳
    • 在Python的Django框架中创建和使用模版
    • python写入xml文件的方法
    • Python中的并发编程实例
    • python计算程序开始到程序结束的运行时间和程序运行的CPU时间
    • Fabric 应用案例
    • 使用wxpython实现的一个简单图片浏览器实例
    • python自动格式化json文件的方法

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

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