Spaces:
Sleeping
Sleeping
File size: 872 Bytes
b9ad6f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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()
|