python 打开sql文件

1
2
3
4
5
6
7
8
9
10
import sqlite3
7 conn=sqlite3.connect('hardwaredb.sqlite')
6 cur= conn.cursor()
5 cur.execute('SELECT * from LogicGates where num=8')
4
3 #conn.commit()
2 f=cur.fetchall()
1 for i in range(12):
9 print '8s%d: %s' %(i+1,f[0][i+2])
1 conn.close()