61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import pymysql
|
|
from datetime import datetime
|
|
|
|
# ==============================
|
|
# ⚙️ CONFIGURATION
|
|
# ==============================
|
|
DB_CONFIG = {
|
|
"host": "192.168.1.76",
|
|
"port": 3307,
|
|
"user": "root",
|
|
"password": "Vlado9674+",
|
|
"database": "medevio",
|
|
"charset": "utf8mb4",
|
|
}
|
|
|
|
REQUEST_ID = "4476f9f8-d7b7-4381-b056-a44897413bcd"
|
|
|
|
# ==============================
|
|
# 🧩 READ CONVERSATION
|
|
# ==============================
|
|
conn = pymysql.connect(**DB_CONFIG)
|
|
cur = conn.cursor(pymysql.cursors.DictCursor)
|
|
|
|
sql = """
|
|
SELECT
|
|
id,
|
|
sender_name,
|
|
text,
|
|
created_at,
|
|
attachment_url,
|
|
attachment_description,
|
|
attachment_content_type
|
|
FROM medevio_conversation
|
|
WHERE request_id = %s
|
|
ORDER BY created_at ASC;
|
|
"""
|
|
|
|
cur.execute(sql, (REQUEST_ID,))
|
|
rows = cur.fetchall()
|
|
|
|
print(f"💬 Conversation for request {REQUEST_ID}:")
|
|
print("─" * 100)
|
|
|
|
for r in rows:
|
|
created = r["created_at"].strftime("%Y-%m-%d %H:%M") if r["created_at"] else "unknown"
|
|
sender = r["sender_name"] or "(unknown)"
|
|
text = (r["text"] or "").strip().replace("\n", " ")
|
|
|
|
print(f"[{created}] {sender}: {text}")
|
|
|
|
if r["attachment_url"]:
|
|
print(f" 📎 Attachment: {r['attachment_description']} ({r['attachment_content_type']})")
|
|
print(f" URL: {r['attachment_url']}")
|
|
print()
|
|
|
|
cur.close()
|
|
conn.close()
|