Spaces:
Sleeping
Sleeping
Download sqlite_agent.py from kadsai/chatbotComo: direct link, hf CLI and curl.
- Browser
- Download file 872 Bytes
-
https://huggingface.co/spaces/kadsai/chatbotComo/resolve/main/sqlite_agent.py
- Command line
-
hf download hf://spaces/kadsai/chatbotComo/sqlite_agent.py
-
curl -L -o sqlite_agent.py https://huggingface.co/spaces/kadsai/chatbotComo/resolve/main/sqlite_agent.py
872 Bytes
| import sqlite3 | |
| from datetime import datetime | |
| import os | |
| DB_PATH = "reclamations.db" | |
| # Initialiser la base si elle n'existe pas | |
| def init_db(): | |
| with sqlite3.connect(DB_PATH) as conn: | |
| cursor = conn.cursor() | |
| cursor.execute(""" | |
| CREATE TABLE IF NOT EXISTS reclamations ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| message TEXT, | |
| user_timestamp TEXT, | |
| status TEXT | |
| ) | |
| """) | |
| conn.commit() | |
| def enregistrer_reclamation(message: str, status: str = "En attente"): | |
| init_db() | |
| with sqlite3.connect(DB_PATH) as conn: | |
| cursor = conn.cursor() | |
| now = datetime.utcnow().isoformat() | |
| cursor.execute("INSERT INTO reclamations (message, user_timestamp, status) VALUES (?, ?, ?)", | |
| (message, now, status)) | |
| conn.commit() | |