kindle manager
This commit is contained in:
37
tfile/tsqllite.py
Normal file
37
tfile/tsqllite.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#########################################################
|
||||
## @file : tsqlite.py
|
||||
## @desc : test sqlite3
|
||||
## @create : 2020/06/11
|
||||
## @author : Chengan
|
||||
## @email : douboer@gmail.com
|
||||
#########################################################
|
||||
|
||||
|
||||
import sqlite3
|
||||
|
||||
dbname = 'vocab.db'
|
||||
conn = sqlite3.connect(dbname)
|
||||
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
sql1 = '''select * from words;'''
|
||||
sql2 = '''select * from lookups;'''
|
||||
|
||||
# fetch one record
|
||||
cursor.execute(sql2)
|
||||
one=cursor.fetchone()
|
||||
print(one)
|
||||
|
||||
# fetch all records
|
||||
for row in cursor.fetchall():
|
||||
print(row)
|
||||
|
||||
# fetch table structure
|
||||
|
||||
except Exception as e:
|
||||
print('sql failure {}'.format(e))
|
||||
pass
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user