-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_work.py
49 lines (37 loc) · 1.16 KB
/
db_work.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
import sqlite3
class Database:
def __init__(self):
self.connection = sqlite3.connect("status.db", check_same_thread=False)
#AFK?
def get_my_afk(self):
cursor = self.connection.cursor()
request = "SELECT status FROM statuses"
result = cursor.execute(request).fetchone()
return result[0]
def set_my_afk(self, value):
cursor = self.connection.cursor()
request = "UPDATE statuses SET status=?"
cursor.execute(request, (value,))
self.connection.commit()
#ReasonAFK
def get_reason(self):
cursor = self.connection.cursor()
request = "SELECT reason FROM statuses"
result = cursor.execute(request).fetchone()
return result[0]
def set_reason(self, value):
cursor = self.connection.cursor()
request = "UPDATE statuses SET reason=?"
cursor.execute(request, (value,))
self.connection.commit()
#TimeInAFK
def get_time_afk(self):
cursor = self.connection.cursor()
request = "SELECT timeAfk FROM statuses"
result = cursor.execute(request).fetchone()
return result[0]
def set_time_afk(self, value):
cursor = self.connection.cursor()
request = "UPDATE statuses SET timeAfk=?"
cursor.execute(request, (value,))
self.connection.commit()