python sqlite3文档地址:http://docs.python.org/2/library/sqlite3.html

The sqlite3 module was written by Gerhard Häring. It provides a SQL interface compliant with the DB-API 2.0 specification described by PEP 249.

To use the module, you must first create a Connection object that represents the database. Here the data will be stored in the example.db file:

import sqlite3
conn = sqlite3.connect('example.db')

You can also supply the special name :memory: to create a database in RAM.

Once you have a Connection, you can create a Cursor object and call its execute() method to perform SQL commands:

c = conn.cursor()

# Create table
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''') # Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)") # Save (commit) the changes
conn.commit() # We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
 

最新文章

  1. ASP.NET Core的配置(3): 将配置绑定为对象[下篇]
  2. C和指针 第六章 数组名与指针
  3. web app iphone4 iphone5 iphone6 iphone6 Plus响应式布局 适配代码
  4. OceanBase server处理网络包的回调逻辑
  5. canvas实践小实例一 —— 画板工具
  6. js setTimeout
  7. 关于VS2010error RC2170 : bitmap file res\tmp1.bmp is not in 3.00 format
  8. django添加静态文件
  9. Angular2 路由问题修复 、求解
  10. javaWeb学习总结(3)- Servlet总结(servlet的主要接口、类)
  11. [项目记录]一个.net下使用HAP实现的吉大校园通知网爬虫工具:OAWebScraping
  12. RxJava系列6(从微观角度解读RxJava源码)
  13. mysql基本命令总结
  14. ubuntu下安装飞鸽传书
  15. mysql自动断开该连接解决方案
  16. ubuntu 18.04启动samba图形管理界面
  17. React-使用combineReducers完成对数据对拆分管理
  18. 最新Linux系统Ubuntu16.04搭建HUSTOJ(LAMP环境)
  19. iOS 技术篇:__VA_ARGS__实现自定义NSLog
  20. 基于window 7安装ubuntu 18.04双系统

热门文章

  1. ASCII码表(0 - 255)
  2. HDU-1234(string字符串)
  3. 当程序遇到 throw后的处理
  4. ios 限制输入长度
  5. java基础知识(一)
  6. git命令使用方法
  7. 《Effective C++ 》学习笔记——条款11
  8. 在Debian Wheezy 7.3.0上编译安装3.12.14内核
  9. 内容提供者 ContentResolver 数据库 示例 -1
  10. 如何查看Android SDK源码版本