Python 中 sqlite3的使用

Python 中 sqlite3的使用

一、sqlite安装

下载地址 http://www.sqlite.org

1、数据库生成

sqlite3.exe testdb

 

2、创建表格,插入数据

 

3、在Python当中进行调用

import sqlite3

##没有密码等设置

con = sqlite3.connect('testdb')

cur = con.cursor()



cur.execute('insert into student (id,name,age) values (1001,\'xiaoming\',22)')

r = cur.execute('delete from student where age = 20')

con.commit()



cur.execute('select * from student')

s = cur.fetchall()

print s

cur.close()

con.close()

 

你可能感兴趣的:(sqlite3)