-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataSQL.py
More file actions
54 lines (38 loc) · 1.38 KB
/
Copy pathDataSQL.py
File metadata and controls
54 lines (38 loc) · 1.38 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
42
43
44
45
46
47
48
49
50
51
52
import sqlite3
def addWidgets():
conn = sqlite3.connect('smt_database.db')
cursor = conn.cursor()
a = True
while(a):
corec = True
while(corec):
id = input("ID: ")
name = input("NAME: ")
widClass = input("CLASS: ")
css_name = input("CSS NAME: ")
wrongInfo = input(f"\n\nIS THIS CORRECT\nID: {id}\nNAME: {name}\nCLASS: {widClass}\nCSS NAME: {css_name}\nY or N: ")
if(wrongInfo == "y" or wrongInfo == "Y"):
corec = False
query = "INSERT INTO widgets (id, name, class, css_name) VALUES (?, ?, ?, ?)"
data = (id, name, widClass, css_name)
cursor.execute(query, data)
stop = input("Add more (Q) to quit: ")
if(stop == "q" or stop == "Q"):
a = False
conn.commit()
conn.close()
def add_layout(client_id, widget_id, row, col):
conn = sqlite3.connect('smt_database.db')
cursor = conn.cursor()
query = "INSERT INTO client_layouts (client_id, widget_id, row, col) VALUES (?, ?, ?, ?)"
data = (client_id, widget_id, row, col)
cursor.execute(query, data)
conn.commit()
conn.close()
def del_widget(widgetID):
conn = sqlite3.connect('smt_database.db')
cursor = conn.cursor()
query = "DELETE FROM widgets WHERE id = ?"
cursor.execute(query, (widgetID,))
conn.commit()
conn.close()