Add add_to_db, update_db to base_quest
This commit is contained in:
parent
d9e9104c93
commit
15dc9c5575
16
questable.py
16
questable.py
|
@ -21,6 +21,22 @@ class base_quest():
|
||||||
else:
|
else:
|
||||||
date = None
|
date = None
|
||||||
|
|
||||||
|
def add_to_db(self):
|
||||||
|
cursor = self.DB.cursor()
|
||||||
|
query = (f'INSERT INTO {self.TABLE}(chat_id, qid, name, importance'
|
||||||
|
', difficulty, date, state) values(?, ?, ?, ?, ?, ?, ?)')
|
||||||
|
cursor.execute(query, (self.CHAT_ID, self.QID, self.name, self.imp,
|
||||||
|
self.diff, self.date, self.state))
|
||||||
|
self.DB.commit()
|
||||||
|
|
||||||
|
def update_db(self):
|
||||||
|
cursor = self.DB.cursor()
|
||||||
|
query = (f'UPDATE {self.TABLE} SET name=?, importance=?, difficulty=?,'
|
||||||
|
' date=?, state=? WHERE chat_id=? AND qid=?')
|
||||||
|
cursor.execute(query, (self.name, self.imp, self.diff, self.date,
|
||||||
|
self.state, self.CHAT_ID, self.QID))
|
||||||
|
self.DB.commit()
|
||||||
|
|
||||||
|
|
||||||
class quest(base_quest):
|
class quest(base_quest):
|
||||||
TABLE = "quests"
|
TABLE = "quests"
|
||||||
|
|
Loading…
Reference in New Issue