Add MedicusWithClaude project - DB exploration scripts and notes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
35
MedicusWithClaude/sample_rtf.py
Normal file
35
MedicusWithClaude/sample_rtf.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import fdb
|
||||
|
||||
conn = fdb.connect(
|
||||
dsn=r'localhost:c:\medicus 3\data\medicus.fdb',
|
||||
user='SYSDBA', password='masterkey', charset='win1250'
|
||||
)
|
||||
cur = conn.cursor()
|
||||
|
||||
# Načti všechny záznamy pacienta a zjisti délku v Pythonu
|
||||
cur.execute("""
|
||||
SELECT ID, DATUM, DEKURS
|
||||
FROM DEKURS
|
||||
WHERE IDPAC = 9742 AND DEKURS IS NOT NULL
|
||||
ORDER BY DATUM DESC
|
||||
""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
def read_blob(val):
|
||||
text = val.read() if hasattr(val, 'read') else val
|
||||
if isinstance(text, bytes):
|
||||
text = text.decode('windows-1250', errors='replace')
|
||||
return text
|
||||
|
||||
# Seřaď podle délky
|
||||
data = [(r[0], r[1], read_blob(r[2])) for r in rows]
|
||||
data.sort(key=lambda x: len(x[2]), reverse=True)
|
||||
|
||||
print("Top 10 nejdelších záznamů:")
|
||||
for d in data[:10]:
|
||||
print(f" ID={d[0]} datum={d[1]} délka={len(d[2])}")
|
||||
|
||||
print("\n--- Nejdelší záznam (celý RTF) ---")
|
||||
print(data[0][2])
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user