Spaces:
Sleeping
Sleeping
Delete user_data.py
Browse files- user_data.py +0 -37
user_data.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
import sqlite3
|
| 2 |
-
import os
|
| 3 |
-
db_path = os.path.join("data", "user_docs.db")
|
| 4 |
-
|
| 5 |
-
def init_db():
|
| 6 |
-
conn = sqlite3.connect(db_path)
|
| 7 |
-
cursor = conn.cursor()
|
| 8 |
-
cursor.execute('''
|
| 9 |
-
CREATE TABLE IF NOT EXISTS user_docs (
|
| 10 |
-
user_id TEXT,
|
| 11 |
-
doc_id TEXT
|
| 12 |
-
)
|
| 13 |
-
''')
|
| 14 |
-
conn.commit()
|
| 15 |
-
conn.close()
|
| 16 |
-
init_db()
|
| 17 |
-
def user_doc(user_id: str, doc_id: str):
|
| 18 |
-
conn = sqlite3.connect(db_path)
|
| 19 |
-
cursor = conn.cursor()
|
| 20 |
-
cursor.execute('''
|
| 21 |
-
INSERT INTO user_docs (user_id, doc_id)
|
| 22 |
-
VALUES (?, ?)
|
| 23 |
-
''', (user_id, doc_id))
|
| 24 |
-
conn.commit()
|
| 25 |
-
conn.close()
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
def get_docs_by_user(user_id: str):
|
| 29 |
-
conn = sqlite3.connect(db_path)
|
| 30 |
-
cursor = conn.cursor()
|
| 31 |
-
cursor.execute('''
|
| 32 |
-
SELECT user_id, doc_id FROM user_docs WHERE user_id = ?
|
| 33 |
-
''', (user_id,))
|
| 34 |
-
results = cursor.fetchall()
|
| 35 |
-
conn.close()
|
| 36 |
-
return results
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|