-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
45 lines (32 loc) · 1.19 KB
/
test.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
import sqlite3
def deleteDataFromLoginKey():
with sqlite3.connect('login_notification_data.db') as conn:
cursor = conn.cursor()
cursor.execute('DELETE FROM login_key')
conn.commit()
def deleteDataFromNotifications():
with sqlite3.connect('login_notification_data.db') as conn:
cursor = conn.cursor()
cursor.execute('DELETE FROM notifications')
conn.commit()
def addUser():
valid_email = '[email protected]'
key = '42c32c42'
try:
with sqlite3.connect('login_notification_data.db') as conn:
cursor = conn.cursor()
# Ensure the table exists (optional, if you are certain the table exists, you can skip this)
cursor.execute('''
CREATE TABLE IF NOT EXISTS login_key (
user TEXT NOT NULL,
key TEXT NOT NULL
)
''')
cursor.execute(
'INSERT INTO login_key(user, key) VALUES (?, ?)', (valid_email, key))
conn.commit()
print("Record inserted successfully.")
except sqlite3.Error as e:
print(f"An error occurred: {e}")
deleteDataFromNotifications()
deleteDataFromLoginKey()