

代码:(推荐学习:Python视频教程)
import sqlite3
with sqlite3.connect(":memory:") as con:
c=con.cursor() #创建游标
c.execute('''CREATE TABLE sensors(data text,city text,code text,sensor_id real,temperature real)''') #新建表,text和real分别表示字符串和数值的类型
for table in c.execute("SELECT name FROM sqlite_master WHERE type='table'"):
print "Table",table[0]
c.execute("INSERT INTO sensors VALUES ('2016-11-05','Utrecht','Red',42,15.14)")
c.execute("SELECT * FROM sensors")
print c.fetchone() #运行结果:
Table sensors (u'2016-11-05', u'Utrecht', u'Red', 42.0, 15.14) # of tables 0
关系型数据库管理系统
嵌入式数据库,适用于嵌入式设备
SQLite不是C/S的数据库引擎
集成在用户程序中
实现了大多数SQL标准
更多Python相关技术文章,请访问Python教程栏目进行学习!
