mirror of
				https://gitlab.com/questable/questable_bot
				synced 2025-10-30 20:00:06 +01:00 
			
		
		
		
	Set up sqlite database.
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,2 +1,3 @@ | ||||
| config.py | ||||
| questable.db | ||||
| __pycache__/ | ||||
|   | ||||
							
								
								
									
										25
									
								
								bot.py
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								bot.py
									
									
									
									
									
								
							| @@ -2,6 +2,7 @@ | ||||
|  | ||||
| import logging | ||||
| import telegram | ||||
| import sqlite3 | ||||
| from telegram.ext import Updater, CommandHandler | ||||
|  | ||||
| try: | ||||
| @@ -29,6 +30,30 @@ def start(bot, update): | ||||
|     bot.send_message(chat_id=chat_id, text=text, reply_markup=reply_markup) | ||||
|  | ||||
|  | ||||
| db = sqlite3.connect("questable.db") | ||||
| cursor = db.cursor() | ||||
| # Set up tables | ||||
| queries = [ | ||||
|        ("CREATE TABLE IF NOT EXISTS quests(user_id int NOT NULL, qid int NOT" | ||||
|            " NULL, name varchar(255) NOT NULL, difficulty int NOT NULL, " | ||||
|            "importance int NOT NULL, completed int NOT NULL, date int NOT NULL" | ||||
|            ", state int NOT NULL DEFAULT 0, UNIQUE(user_id, qid));"), | ||||
|  | ||||
|        ("CREATE TABLE IF NOT EXISTS side_quests(user_id int NOT NULL, qid int" | ||||
|            " NOT NULL, name varchar(255) NOT NULL, difficulty int NOT NULL, " | ||||
|            "importance int NOT NULL, completed int NOT NULL, date int NOT NULL" | ||||
|            ", state int NOT NULL DEFAULT 0, UNIQUE(user_id, qid));"), | ||||
|  | ||||
|        ("CREATE TABLE IF NOT EXISTS points(user_id int PRIMARY KEY, points " | ||||
|            "int);"), | ||||
|  | ||||
|        ("CREATE TABLE IF NOT EXISTS state(user_id int PRIMARY KEY, state " | ||||
|            "varchar(10));"), | ||||
|         ] | ||||
| for query in queries: | ||||
|     cursor.execute(query) | ||||
| db.commit() | ||||
|  | ||||
| updater = Updater(token=config.api_key) | ||||
| dispatcher = updater.dispatcher | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user