-
Notifications
You must be signed in to change notification settings - Fork 1
/
SQLiteDB.py
31 lines (25 loc) · 962 Bytes
/
SQLiteDB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sqlite3
class sqlite_db:
def __init__(self, path):
self.path = path
def create_sqlite(self):
con = sqlite3.connect(self.path) # database create
con.text_factory = str()
cursor = con.cursor()
sql = "CREATE TABLE IF NOT EXISTS richdrs(" \
"Filename text, " \
"Filepath text, " \
"MD5 text, " \
"SHA1 text, " \
"mCV text, " \
"Count text, " \
"ProdID text)"
cursor.execute(sql)
def insert_sqlite(self, fname, fpath, md5, sha1, mcv, cnt, pid):
con = sqlite3.connect(self.path)
con.text_factory = str()
cursor = con.cursor()
cursor.execute("INSERT INTO richdrs VALUES(?,?,?,?,?,?,?)",
(str(unicode(fname).encode('utf8')), str(unicode(fpath).encode('utf8')), md5, sha1, str(mcv), str(cnt), str(pid)))
con.commit()
con.close()