-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL_Mod.py
More file actions
41 lines (33 loc) · 1.27 KB
/
SQL_Mod.py
File metadata and controls
41 lines (33 loc) · 1.27 KB
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
# SQL DATABASE MODULE.
# By Kevin Caplescu.
import sqlite3
import sys
class Database():
def __init__(self):
self.Connection = sqlite3.connect('userdatabase')
print("Successfully created SQL Database.\nCursor created.")
self.Cursor = self.Connection.cursor()
self.Cursor.execute("""CREATE TABLE IF NOT EXISTS localdatabase
(key text,theme text)""")
result = self.Cursor.execute("SELECT key FROM localdatabase")
if result.fetchone() == None:
self.Cursor.execute("""INSERT INTO localdatabase VALUES
('','default')""")
self.Connection.commit()
else:
pass
def _SaveProtocol(self):
self.Connection.commit()
self.Cursor.close()
self.Connection.close()
sys.exit()
def _ExecuteCommand(self,cmd):
return_list = []
try:
c = self.Cursor.execute(cmd)
if str.find(cmd,"SELECT") > -1:
return_list.append(c.fetchone())
self.Connection.commit()
return(return_list)
except:
print("================\nFailure to execute command\n===================:")