This commit is contained in:
Arseniy Romenskiy 2025-12-27 05:02:10 +03:00
commit 02f3a1b884
32 changed files with 5597 additions and 0 deletions

32
db_module.py Normal file
View file

@ -0,0 +1,32 @@
import sqlite3
import os
put = os.path.dirname(os.path.realpath(__file__)) + "/" #Путь- (part-1)
DB_PATH = put + "data.sqlite3"
bd = sqlite3.connect(DB_PATH)
sql = bd.cursor()
sql.execute("""CREATE TABLE IF NOT EXISTS rs_user (
user_id INTEGER PRIMARY KEY AUTOINCREMENT,
user_name TEXT NOT NULL,
email TEXT,
password TEXT,
avatar INTEGER NOT NULL DEFAULT 0,
active INTEGER NOT NULL DEFAULT 0
);""")
sql.close()
def check_user(email: str, password: str):
conn = sqlite3.connect(DB_PATH)
conn.row_factory = sqlite3.Row
try:
row = conn.execute(
"SELECT user_id, user_name, active FROM rs_user WHERE email = ? AND password = ?",
(email, password),
).fetchone()
if row is None:
return None, None, None
return int(row["user_id"]), row["user_name"], int(row["active"])
finally:
conn.close()