31 lines
666 B
Python
Executable File
31 lines
666 B
Python
Executable File
import sqlite3
|
|
|
|
conn = sqlite3.connect("Goonerdle.db")
|
|
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute("""
|
|
CREATE TABLE Score (
|
|
Score_ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
Result_ID INTEGER,
|
|
Position INTEGER,
|
|
isCorrect INTEGER NOT NULL CHECK (isCorrect IN (0,1)),
|
|
FOREIGN KEY (Result_ID) REFERENCES Result(Result_ID)
|
|
);
|
|
""")
|
|
|
|
cursor.execute("""
|
|
CREATE TABLE Result (
|
|
Result_ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
User_ID INTEGER NOT NULL,
|
|
DateScore DATE NOT NULL,
|
|
Result INTEGER NOT NULL,
|
|
UNIQUE (User_ID, DateScore)
|
|
);
|
|
""")
|
|
|
|
conn.commit()
|
|
|
|
conn.close()
|
|
|
|
print("Database and tables created successfully!") |