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