Download data/database.py from Rogersurf/reborn: direct link, hf CLI and curl.
- Browser
- Download file 943 Bytes
-
https://huggingface.co/spaces/Rogersurf/reborn/resolve/main/data/database.py
- Command line
-
hf download hf://spaces/Rogersurf/reborn/data/database.py
-
curl -L -o database.py https://huggingface.co/spaces/Rogersurf/reborn/resolve/main/data/database.py
943 Bytes
| # data/database.py | |
| import sqlite3 | |
| from core.settings import settings | |
| class Database: | |
| def __init__(self): | |
| self.conn = sqlite3.connect(settings.DATABASE_PATH, check_same_thread=False) | |
| self._create_tables() | |
| def _create_tables(self): | |
| cursor = self.conn.cursor() | |
| cursor.execute(""" | |
| CREATE TABLE IF NOT EXISTS questions ( | |
| id TEXT PRIMARY KEY, | |
| statement TEXT, | |
| options TEXT, | |
| correct_answer TEXT, | |
| explanation TEXT, | |
| topic TEXT, | |
| difficulty INTEGER | |
| ) | |
| """) | |
| cursor.execute(""" | |
| CREATE TABLE IF NOT EXISTS answers ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| question_id TEXT, | |
| correct BOOLEAN, | |
| timestamp DATETIME DEFAULT CURRENT_TIMESTAMP | |
| ) | |
| """) | |
| self.conn.commit() |