Create a new user profile
(user_id: str, profile_json: Dict)
| 534 | # ============== Profile Operations ============== |
| 535 | |
| 536 | def create_profile(user_id: str, profile_json: Dict) -> Optional[int]: |
| 537 | """Create a new user profile""" |
| 538 | conn = get_connection() |
| 539 | cursor = conn.cursor() |
| 540 | try: |
| 541 | cursor.execute(""" |
| 542 | INSERT INTO profiles (user_id, profile_json, version) |
| 543 | VALUES (?, ?, ?) |
| 544 | """, (user_id, json.dumps(profile_json), profile_json.get("version", "0.1"))) |
| 545 | conn.commit() |
| 546 | profile_id = cursor.lastrowid |
| 547 | print(f"Profile created with id: {profile_id}") |
| 548 | return profile_id |
| 549 | except sqlite3.IntegrityError: |
| 550 | print(f"Profile already exists for user: {user_id}") |
| 551 | return None |
| 552 | finally: |
| 553 | conn.close() |
| 554 | |
| 555 | |
| 556 | def save_paper( |