python sqlite3使用
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()
python sqlite3使用的更多相关文章
- python sqlite3 数据库操作
python sqlite3 数据库操作 SQLite3是python的内置模块,是一款非常小巧的嵌入式开源数据库软件. 1. 导入Python SQLite数据库模块 import sqlite3 ...
- python sqlite3 入门 (视频讲座)
python sqlite3 入门 (视频讲座) an SQLite mini-series! - Simple Databases with Python 播放列表: YouTube https:/ ...
- python sqlite3简单操作
python sqlite3简单操作(原创)import sqlite3class CsqliteTable: def __init__(self): pass def linkSqlite3(sel ...
- python+sqlite3
一个小例子, # -*- coding:utf-8 -*- ''' Created on 2015年10月8日 (1.1)Python 2.7 Tutorial Pt 12 SQLite - http ...
- [Python]sqlite3二进制文件存储问题(BLOB)(You must not use 8-bit bytestrings unless you use a text_factory...)
事情是这种: 博主尝试用Python的sqlite3数据库存放加密后的usernamepassword信息,表是这种 CREATE TABLE IF NOT EXISTS user ( userID ...
- xls===>csv tables===via python ===> sqlite3.db
I've got some files which can help a little bit to figure out where people are from based on their I ...
- Python sqlite3操作笔记
创建数据库 def create_tables(dbname): conn = sqlite3.connect(dbname) print "Opened database successf ...
- python sqlite3 MySQLdb
SQLite是一种嵌入式数据库,它的数据库就是一个文件.由于SQLite本身是C写的,而且体积很小,所以,经常被集成到各种应用程序中,甚至在iOS和Android的App中都可以集成. Python就 ...
- python sqlite3操作类扩展,包含数据库分页
一.原因 最近在使用python3和sqlite3编辑一些小程序,由于要使用数据库,就离不开增.删.改.查,sqlite3的操作同java里的jdbc很像,于是就想找现成的操作类,找来找去,发现一个 ...
随机推荐
- cocos2d-x多分辨率适配原理分析(2.0.4之后的版本)
2013年11月4日补充: 之前写这篇博客的时候其实我还没有开始过真正的去做一个项目,主要过程还是偏向于理解原理.前几天在准备练练手时回过头来想了下这个问题,发现又有点一头雾水了,所以我觉得之前我并没 ...
- Node开发入门
介绍 Node.js采用google的V8虚拟机来解释和执行javascript,也就是允许脱离浏览器环境运行javascript代码. Hello World 婴儿说的第一个字一般是"妈& ...
- C# 利用反射查看类的信息
using System; using System.Collections; using System.Collections.Generic; using System.Reflection; u ...
- BeanFactory调用getbean()对象
Spring通过资源加载器加载相应的XML文件,使用读取器读取资源加载器中的文件到读取器中,在读取过程中,解析相应的xml文件元素,转化为spring定义的数据结BeanDefinition,把相应的 ...
- MySQL删除外键定义的方法
MySQL外键在定以后,如果我们不再需要这个外键,可以进行删除操作,下面就为您介绍MySQL删除外键定义的方法,供您参考. 不知道大家有没有发现,在定义外键的时候articles.member_id外 ...
- SSO跨域解决方案
单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一.SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统.它包括可 以将 ...
- 经常使用ASCII码表(方便查找)
经常使用ASCII码表(方便查找) 键盘 ASCII码 键盘 ASCII码 键盘 ASCII码 键盘 ASCII码 ESC 27 7 55 O 79 g 103 SPACE 32 8 56 P 80 ...
- HDU 5067-Harry And Dig Machine(DFS)
Harry And Dig Machine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- _getch() 和 getch() 及 _T()
带下划线_的函数一般是函数库内部的函数,而不带下划线的一般是提供给用户使用的函数.带下划线的目的是为了防止用户定义的函数和函数库的函数重名冲突,所以直接使用也是可以的.要用getch()必须引入头文件 ...
- html表格标签与属性
标记: 标 记 说 明 <Table> 表格标记 <Tr> 行标记 <Td> 单元格标记 <Th> 表头标记 <Table>标记属性: ...