Add MedicusWithClaude project - DB exploration scripts and notes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
45
MedicusWithClaude/explore_db.py
Normal file
45
MedicusWithClaude/explore_db.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
Průzkum Medicus databáze – výpis tabulek a jejich sloupců.
|
||||
"""
|
||||
import fdb
|
||||
|
||||
conn = fdb.connect(
|
||||
dsn=r'localhost:c:\medicus 3\data\medicus.fdb',
|
||||
user='SYSDBA',
|
||||
password='masterkey',
|
||||
charset='win1250'
|
||||
)
|
||||
|
||||
cur = conn.cursor()
|
||||
|
||||
# Všechny uživatelské tabulky
|
||||
cur.execute("""
|
||||
SELECT rdb$relation_name
|
||||
FROM rdb$relations
|
||||
WHERE rdb$view_blr IS NULL
|
||||
AND (rdb$system_flag IS NULL OR rdb$system_flag = 0)
|
||||
ORDER BY rdb$relation_name
|
||||
""")
|
||||
tables = [row[0].strip() for row in cur.fetchall()]
|
||||
|
||||
print(f"Počet tabulek: {len(tables)}\n")
|
||||
print("=== SEZNAM TABULEK ===")
|
||||
for t in tables:
|
||||
print(f" {t}")
|
||||
|
||||
print("\n=== SLOUPCE KAŽDÉ TABULKY ===")
|
||||
for table in tables:
|
||||
cur.execute("""
|
||||
SELECT rf.rdb$field_name, f.rdb$field_type, f.rdb$field_length
|
||||
FROM rdb$relation_fields rf
|
||||
JOIN rdb$fields f ON rf.rdb$field_source = f.rdb$field_name
|
||||
WHERE rf.rdb$relation_name = ?
|
||||
ORDER BY rf.rdb$field_position
|
||||
""", (table,))
|
||||
cols = cur.fetchall()
|
||||
col_names = [c[0].strip() for c in cols]
|
||||
print(f"\n{table}")
|
||||
print(" " + ", ".join(col_names))
|
||||
|
||||
cur.close()
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user