Spaces:
Sleeping
Sleeping
Download embed.py from HarshitX/PDF_Questionnaire_App: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/HarshitX/PDF_Questionnaire_App/resolve/main/embed.py
- Command line
-
hf download hf://spaces/HarshitX/PDF_Questionnaire_App/embed.py
-
curl -L -o embed.py https://huggingface.co/spaces/HarshitX/PDF_Questionnaire_App/resolve/main/embed.py
1.11 kB
| import sqlite3 | |
| def create_connection(): | |
| conn = sqlite3.connect("user_data.db") | |
| return conn | |
| def create_table(): | |
| conn = create_connection() | |
| cursor = conn.cursor() | |
| cursor.execute(""" | |
| CREATE TABLE IF NOT EXISTS users( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| username TEXT UNIQUE NOT NULL, | |
| password TEXT NOT NULL | |
| ) | |
| """) | |
| conn.commit() | |
| conn.close() | |
| def add_user(username, password): | |
| conn = create_connection() | |
| cursor = conn.cursor() | |
| cursor.execute(""" | |
| INSERT INTO users(username, password) VALUES (?, ?) | |
| """, (username, password)) | |
| conn.commit() | |
| conn.close() | |
| def peek(): | |
| conn = create_connection() | |
| cursor = conn.cursor() | |
| cursor.execute(""" | |
| SELECT * FROM users | |
| """) | |
| users = cursor.fetchall() | |
| for user in users: | |
| print(user) | |
| conn.close() | |
| def verify_user(username, password): | |
| conn = create_connection() | |
| cursor = conn.cursor() | |
| cursor.execute(""" | |
| SELECT * FROM users | |
| WHERE username = ? AND password = ? | |
| """, (username, password)) | |
| user = cursor.fetchone() | |
| conn.close() | |
| return user |