-
Notifications
You must be signed in to change notification settings - Fork 1
/
support_sql.py
60 lines (51 loc) · 1.35 KB
/
support_sql.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sqlite3
import os
import time
import sys
import platform
import logging
import ctypes
import math
import os
import logging
import support
log = logging.getLogger(__name__)
con = sqlite3.connect('case.db')
cursor = con.cursor()
def opendb(case):
global con
global cursor
if os.path.isfile('/Users/deb/Assignment03/case.db') and os.access("case.db", os.R_OK):
con = sqlite3.connect("case.db")
cursor = con.cursor()
else:
con = sqlite3.connect(dbfilename)
cursor = con.cursor()
createNewTables(cursor)
return cursor
def createNewTables(cursor):
query = '''
CREATE Table IF NOT EXISTS CASENAME (
JPGName TEXT, ASCII TEXT, label TEXT, NSFW TEXT
);
'''
cursor = con.cursor()
cursor.executescript(query)
return
def startCase(cursor,casename, Timestamp):
return (current)
def closedb():
global con
con.commit()
con.close()
def insertinto(CASENAME, jpg, cursor, label, nsfw):
#ASCII = "placeholder_for_ascii"
#label = "placeholder_for_label"
query = ('''INSERT INTO CASENAME (JPGName, label, nsfw) VALUES ("%s", "%s","%s")''' % (jpg, label, nsfw))
cursor = con.cursor()
cursor.executescript(query)
if __name__ == '__main__':
CASENAME = 'TestCase'
cursor = opendb('case.db')
createNewTables(cursor)
closedb()