-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_base.py
More file actions
44 lines (37 loc) · 1.23 KB
/
data_base.py
File metadata and controls
44 lines (37 loc) · 1.23 KB
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
import sqlite3
from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
class DataBase:
def __init__(self):
self.con = sqlite3.connect("Morphological_Maven.sqlite3")
self.cur = self.con.cursor()
self.cur.execute("""CREATE TABLE IF NOT EXISTS users (
user_ID INTEGER PRIMARY KEY AUTOINCREMENT
NOT NULL
UNIQUE
REFERENCES tests (user_ID),
login TEXT UNIQUE
NOT NULL,
password TEXT NOT NULL
);
""")
self.cur.execute("""CREATE TABLE IF NOT EXISTS tests (
test_ID INTEGER PRIMARY KEY AUTOINCREMENT
UNIQUE
NOT NULL,
user_ID INTEGER NOT NULL,
test_word TEXT NOT NULL,
test_result INTEGER NOT NULL,
date TEXT NOT NULL,
time TEXT NOT NULL
);
""")
self.con.commit()
def cursor(self):
return self.cur
def connection(self):
return self.con