11#!/usr/bin/env python
22"""Launch DuckDB UI for the database."""
3+
34import sys
45import webbrowser
56from pathlib import Path
7+
68import duckdb
79
810
@@ -11,23 +13,26 @@ def main():
1113 project_root = Path (__file__ ).parent .parent .parent
1214 exploration_dir = project_root / "data" / "exploration"
1315
16+ db_name = "dev.duckdb"
1417 # Default to odis.duckdb, or use command line argument
15- db_name = sys .argv [1 ] if len (sys .argv ) > 1 else "odis.duckdb"
18+ odis_db_name = sys .argv [1 ] if len (sys .argv ) > 1 else "odis.duckdb"
1619 db_file = exploration_dir / db_name
20+ odis_db_file = exploration_dir / odis_db_name
1721
1822 # Check if database exists
19- if not db_file .exists ():
20- print (f"❌ Database not found: { db_file } " )
23+ if not odis_db_file .exists ():
24+ print (f"❌ Database not found: { odis_db_file } " )
2125 print (f"\n Available databases in { exploration_dir } :" )
2226 for db in exploration_dir .glob ("*.duckdb" ):
2327 print (f" - { db .name } " )
2428 sys .exit (1 )
2529
26- print (f"🦆 Launching DuckDB UI for { db_file } ..." )
30+ print (f"🦆 Launching DuckDB UI for { db_file } { odis_db_file } ..." )
2731
2832 # Connect to the database and start UI
2933 conn = duckdb .connect (str (db_file ))
30- result = duckdb .sql ("CALL start_ui();" ).fetchone ()
34+ conn .sql (f"ATTACH DATABASE '{ odis_db_file } ' AS odis;" )
35+ result = conn .sql ("CALL start_ui();" ).fetchone ()
3136
3237 if result and result [0 ]:
3338 url = result [0 ]
@@ -39,6 +44,7 @@ def main():
3944 # Keep the connection alive
4045 try :
4146 import time
47+
4248 while True :
4349 time .sleep (1 )
4450 except KeyboardInterrupt :
0 commit comments